Page 1 of 1

php get specific data in multi array

Posted: Tue Nov 10, 2009 2:37 am
by imin
hi

i have a multi array data, which when printed using print_r, it's displayed like this:

Code:

Code: Select all

Array ( [recipes0] => Array ( [recipeID] => TM-ce57 [count] => 2 ) [recipes1] => Array ( [recipeID] => TM-52e2 [count] => 3 ) )
then I sort the data according to the [count] value, descendingly, and now when I print_r the multi array data, it's displayed like this:

Code:

Code: Select all

Array ( [recipes1] => Array ( [recipeID] => TM-52e2 [count] => 3 ) [recipes0] => Array ( [recipeID] => TM-ce57 [count] => 2 ) )
now I need to get the first field of the sorted, which in this case is [recipes1], [recipes0] into some other variables or array, perhaps something like this:
$sortedData[0] = "recipes1";
$sortedData[1] = "recipes0";

how may I do this? any help is greatly greatly appreciated, since I am stucked with this problem since yesterday

thanks

Re: php get specific data in multi array

Posted: Tue Nov 10, 2009 3:38 am
by josh

Re: php get specific data in multi array

Posted: Wed Nov 11, 2009 9:45 pm
by imin
thanks a lot everyone .. i got what i need by using foreach :D..