multidimesional array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lokesh_kumar_s
Forum Commoner
Posts: 48
Joined: Mon Apr 13, 2009 5:39 am
Contact:

multidimesional array

Post 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
User avatar
susrisha
Forum Contributor
Posts: 439
Joined: Thu Aug 07, 2008 11:43 pm
Location: Hyderabad India

Re: multidimesional array

Post 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..
Post Reply