Using extract () function with Multidimensional array?

Discussion in 'PHP' started by XO39, Dec 18, 2008.

  1. #1
    Hi there,

    I am learning PHP recent days and there is still a lot of things that I don't know about yet and trying to figure out how to do thing within php.

    Anyway, I just came across extract () function which can extract variables from an array and set every elements in an array as a variable (as I'm sure you know that :D ). and I think that is just cool.

    My question is:

    Does the function work with multidimensional array as well?
    another question:

    Is there any built-in function or any other way to extract variables from multidimensional arrays?

    Thanks guys. :)
     
    XO39, Dec 18, 2008 IP
  2. Kaizoku

    Kaizoku Well-Known Member

    Messages:
    1,261
    Likes Received:
    20
    Best Answers:
    1
    Trophy Points:
    105
    #2
    Do you mean recursive? If so, I don't think so.

    $a['one']['two'] = 12;
    extract($a);

    Will just give
    $one = array('two' => 12);

    extract() is not really useful, it just adds more useless memory in the script.
     
    Kaizoku, Dec 18, 2008 IP
  3. XO39

    XO39 Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    yes I know and that what I got when tried this function with multidimensional arrays.
    so I thought maybe there must be a similar function which works with multidimensional just like exTRact () works and variables from a normal array.

    I'm just trying to discover and understand things in PHP as I'm still a newbie.

    thanks Kaizoku

    if anyone has any other idea please let me know.

    :)
     
    XO39, Dec 19, 2008 IP