php array to file

Now you can easily store multidimensional array into file.There is some sitution when you need to store multidimensional array into file.For example you want to debug some output (Example IPN).There is no way to debug ipn so you want to write post variable or other variable to file then you can store this array to file directly.

  

$yourArry=array(

'0'=>'test1',
'1'=>'test2',
'2'=>array(
'0'=>'test1',
'1'=>'test2',
'3'=>array(
'0'=>'test 0',
'1'=>'test 1',
'2'=>'test 2',
)
),
'3'=>'test 3'
);

ob_start();
print_r( $yourArry);
$output = ob_get_clean();
file_put_contents( 'yourfilename.txt',$output );

Leave a Reply

Your email address will not be published. Required fields are marked *