Output (echo/print) everything from a PHP Array

后端 未结 9 891
無奈伤痛
無奈伤痛 2020-12-06 16:21

Is it possible to echo or print the entire contents of an array without specifying which part of the array?

The scenario: I am trying to echo everything from:

<
9条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-06 17:08

     //@parram $data-array,$d-if true then die by default it is false
     //@author Your name
    
     function p($data,$d = false){
    
         echo "
    "; 
             print_r($data);
         echo "
    "; if($d == TRUE){ die(); } } // END OF FUNCTION

    Use this function every time whenver you need to string or array it will wroks just GREAT.
    There are 2 Patameters
    1.$data - It can be Array or String
    2.$d - By Default it is FALSE but if you set to true then it will execute die() function

    In your case you can use in this way....

    while($row = mysql_fetch_array($result)){
        p($row); // Use this function if you use above function in your page.
    }
    

提交回复
热议问题