PHP array output Three forms of PHP print array

Source: Internet
Author: User
Tags php print

PHP Array output Three forms of PHP print array

$BBBB =array ("one" = "AAA", "All" = "BBB");
Mode one: Only output value cannot output key
foreach ($bbbb as $color)
Echo $color;


Method Two: Both value and key can be output
foreach ($bbbb as $key = $value)
echo $key. " = ". $value;


Method Three: Both value and key can be output
while ($color =each ($bbbb)) {
echo $color [' key '];
}


Print_r ()

Var_dump ()

<?
$a = Array (1, 2, Array ("A", "B", "C"));
Var_dump ($a);
?>

Output Result:
Array (3) {
[0]=>
Int (1)
[1]=>
Int (2)
[2]=>
Array (3) {
[0]=>
String (1) "a"
[1]=>
String (1) "B"
[2]=>
String (1) "C"
}
}

PHP array output Three forms of PHP print array

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.