SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2000
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help getting 'Keys' out of multi-dimensional array

    Hi,

    Could anyone advise me on the most simple and efficient way of getting 'keys' out of a multi-dimensional array.

    I have the multi-dimensional Array :

    PHP Code:
    $C_L_P_CurrentPage[][][] 
    This array stores the relationships between $C[] , $L[] & $P[] as Keys, which I then want to use in individual queries. Rather than having to use 3 loops to get the inforamtion (I want to get all the keys for each sub-array) is there not an easier more efficient function I could use ?? I tried the below but it through out errors as I can't use [] for reading.

    PHP Code:
        $C_QUERY_ids array_keys($C_L_P_CurrentPage);
        
    $L_QUERY_ids array_keys($C_L_P_CurrentPage[]);
        
    $P_QUERY_ids array_keys($C_L_P_CurrentPage[][]);); 
    Many Thanks

  2. #2
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You somehow have to go through all the dimension of the array to get all the keys, so no, you'll have to do this manually. Of course, there could be a PHP function that did this, but I don't think it would be used much


Bookmarks

Posting Permissions

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