This article introduces an example code for outputting beautiful format arrays in PHP. Friends in need can refer to it.
php output array format, preset beautiful format, worth your reference: Copy code Code example: "; print_r($object); echo ""; } else{ echo htmlspecialchars($object); } } ?>Attached are three common methods for outputting arrays in PHP. Copy code Code example:
//Array for testing $bbbb=array("11"=>"aaa","22"=>"bbb"); //Method 1: Only the value can be output but not the key foreach($bbbb as $color) echo $color; //Method 2: Both value and key can be output foreach($bbbb as $key=>$value) echo $key."=>".$value; //Method 3: Both value and key can be output while($color=each($bbbb)){ echo $color['key']; } ?> That’s it. I hope the above code snippets about php array output will be helpful to everyone. |