Page 1 of 1

multidimesional array

Posted: Sat Apr 18, 2009 3:37 am
by lokesh_kumar_s
hi i am having some problem

i am using two dimensional arrays

user[$userId][$codes] both userId and codes are arbitrary

i am storing somthing in this multidimensional array and to retrieve using
$sub="";
foreach(user as usr)
{
foreach(usr as cds)
{
//here i want the value of $codes how can i retrieve that
}
}
for example
if
user[01][123]=xxx
then i need 123 as a variable i want it to concatinate to $sub
please help

Re: multidimesional array

Posted: Sat Apr 18, 2009 5:09 am
by susrisha

Code: Select all

 
<?php
    $user = array();
    $user[1][100]="this is hundred";
    $user[1][101]= "this is hundred one";
    $user[2][100]="user 2 hundred";
    $user[2][101]="user 2 hundred one";
    foreach($user as $usr)
    {
        foreach($usr as $code=>$description)
        {
            echo "$code";
            //echo "Description is $description\n";
        }
    }
    
?>
 
Have a look at this..