CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2005
    Posts
    141

    Question php get specific data in multi array

    hi

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

    Code:
    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:
    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

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: php get specific data in multi array

    Have you tried the many different sorting functions built into PHP? Don't forget you can also recurse arrays with foreach() and for().

    I'm sorry, but you're not being clear. Can you explain yourself a little better?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Jul 2005
    Posts
    141

    Re: php get specific data in multi array

    Quote Originally Posted by PeejAvery View Post
    Have you tried the many different sorting functions built into PHP? Don't forget you can also recurse arrays with foreach() and for().

    I'm sorry, but you're not being clear. Can you explain yourself a little better?


    yup2, thanks a lot .. i got what i need by using foreach

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured