1. For foreach in fact the $key=> $value and $i = $g is the same effect, and is not limited to key value
echo "
\ n ";
$arr = Array ("One", "one", "three");
foreach ($arr as $i = = $g) {
echo "Key: $i; Value: $g
\ n ";
}
?>
2. Array_fill () function
Fills an array with the given value
$a = Array_fill (5, 6, ' banana ');
Print_r ($a);
?>
Output:
Array ([5] = banana [6] = banana [7] = banana [8] = banana [9] = = Banana [ten] = banana)
3. Print Array (PHP mode and JSON mode)
$data = Array (
' FirstName ' = ' Tom ',
' LastName ' = ' Smith ',
' Age ' =>40
);
Print_r ($data);
echo Json_encode ($data);
Output:
Array ([FirstName] = Tom [LastName] = Smith [age] + 40)
{"FirstName": "Tom", "LastName": "Smith", "Age": 40}
4. Print_r ($data, true); So you can write the array into the log www.2cto.com
$a = Array ("A", "B", "C");
$c = Print_r ($a, true);
$logfile = "T.txt";
Error_log ("{$c}\r\n\r\n", 3, $logfile);
Excerpt from Hata Lishin's Crazy coding life
http://www.bkjia.com/PHPjc/478354.html www.bkjia.com true http://www.bkjia.com/PHPjc/478354.html techarticle 1. For foreach actually using $key= $value and $i = $g is the same effect, and is not limited to key value? PHP echo br/\n; $arr = Array (one, one, three); foreach ($a RR as $i = $g) {echo Key: ...