jeudi 29 janvier 2015

Selection Condition Array In PHP

i have PHP code with loop:



$product = Array();
$idx = $idx2 = 0;
while ($data = oci_fetch_array($stmt, OCI_BOTH)) {
if($data['PARENT'] == 0) {
$idx++;
$product[$idx]['id'] = $data['ID'];
$product[$idx]['name'] = $data['NAME'];
}
else {
$product[$idx][0]['attributeName'] = 'DOWNLOAD';
$product[$idx][0]['attributeValue'] = $data['DOWNLOAD'];
$product[$idx][1]['attributeName'] = 'UPLOAD';
$product[$idx][1]['attributeValue'] = $data['UPLOAD'];
}
}
print_r ($test_array);


the array result is:


Array ( [1] => Array ( [id] => 1 [name] => INTERNET [0] => Array ( [attributeName] => DOWNLOAD [attributeValue] => 2048 )



[1] => Array
(
[attributeName] => UPLOAD
[attributeValue] => 512
)

)

[2] => Array
(
[id] => 2
[name] => VOICE
[0] => Array
(
[attributeName] => DOWNLOAD
[attributeValue] =>
)

[1] => Array
(
[attributeName] => UPLOAD
[attributeValue] =>
)
)
)


But i just want show the attributeName and attributeValue for internet only.. i tried to add if($data['NAME'][0]='INTERNET') below while, but it doesn't work, VOICE still has attributeName and attributeValue. Please Help. Thanks


Aucun commentaire:

Enregistrer un commentaire