Code example of php outputting beautifully formatted array

WBOY
Release: 2016-07-25 08:58:29
Original
1416 people have browsed it
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.



source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!