how can i save the output of array ?

Discussion in 'Programming/Scripts' started by qwe010, Sep 23, 2008.

  1. qwe010

    qwe010 New Member

    hello

    how can i save the output of array in php?


    print_r($array);

    any idea ?
     
  2. topdog

    topdog Active Member HowtoForge Supporter

    what do u mean save it, you already have it in the variable, you can use the contents of the variable at anytime with in the lifespan of the script.
     
  3. Ben

    Ben ISPConfig Developer ISPConfig Developer

    if you want to store it anywhere, to e.g. rebuild again use serialize / unserialize:
    PHP:
    $myarray = array(1,2,3);
    var_dump($myarray);
    $myarraySerialized serialize($myarray);
    unset(
    $myarray);
    var_dump($myarray);
    $myarray unserialize(myarraySerialized);
    var_dump($myarray);
    If you meant to store an print_r / var_dump equivalent output of the array structure the use var_export(your_var, true). The second parameter is important here.
     

Share This Page