Click here to Skip to main content
15,041,525 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
hello I have a array in php, when printing the array it appears to be

JavaScript
Array
(
    [0] => Array
        (
            [pageID] => 1
            [add] => 1
            [view] => 0
            [edit] => 0
            [delete] => 0
        )

    [1] => Array
        (
            [pageID] => 3
            [add] => 0
            [view] => 1
            [edit] => 0
            [delete] => 0
        )

    [2] => Array
        (
            [pageID] => 4
            [add] => 0
            [view] => 0
            [edit] => 1
            [delete] => 0
        )

    [3] => Array
        (
            [pageID] => 6
            [add] => 0
            [view] => 0
            [edit] => 0
            [delete] => 0
        )

)


now i want value for each inside array.

What I have tried:

I have tried using $str[0]->pageID; but its not returning any value. also I have tried using $str->pageID[0] but the result is same
Posted
Updated 20-Jun-16 2:54am

PHP
 foreach($str as $s) {
   $a = $s[pageID];
   $b = $s[add];
   $c = $s[view];
   $d = $s[edit];
   $e = $s[delete];
 }  
?>


Where $a - $e are just for example purposes. You do with them as you wish.

   
try using
PHP
$str[0]['pageID']
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900