In the given example, we have used the print_r() function to print all the values of the array.<!DOCTYPE html> Print all the values of array <?php $fruits = array("Apple", "Mango", "Banana", "Pears", "Watermelon", "Guava"); print_r($fruits); ?> OutputArray ( [0...
print_r() function is one of the built-in functions in PHP used to print or show the contents of a variable. It typically prints a human-readable format about a variable and the value, if it is a string, integer, or float. If you provide an array, it can show the values in a ...
In this post, I will share a short and simple code onhow to print and write array values to files in PHP. If you have a task or problem that needs to write the array value to a file then this is for you. In this example, I'm usingfile_put_contents()to put the value to a f...
"\n"; // prints "Second" // Print the value associated with the key "a" in the "color" sub-array echo $color["color"]["a"] . "\n"; // prints "Red" ?> Output: Second Red Flowchart: PHP Code Editor:Contribute your code and comments through Disqus....
Theprint_rPHP function is used to return an array in a human readable form. It is written as: print_r($your_array) In this example, an array is defined and printed. The tagindicates the following code is preformatted text. This tag causes the text to be displayed in a fixed-width fo...
因为true转换成了1
;// 可以在打印语句中使用变量$foo = "foobar";$bar = "barbaz";print "foo is $foo"; // foo is foobar// 也可以使用数组$bar = array("value" => "foo");print "this is {$bar['value']} !"; // this is foo !// 使用单引号将打印变量名,而不是变量的值print 'foo is $foo'; /...
Each value of the array$arrayNameis assigned to the variable$variableName. The pointer increments its value in each loop to iterate over the array. <?php//Declare the array$flowers=array("Rose","Lili","Jasmine","Hibiscus","Tulip","Sun Flower","Daffodil","Daisy");echo"The array is:\...
$result .=print_array( $param );else$result .="$b => $param";return$result; } 开发者ID:ruslanBik4,项目名称:allservice_in_ua,代码行数:10,代码来源:params.php 示例7: merge_sort ▲点赞 1▼ functionmerge_sort(&$a, $l =0, $r =-1, $tmp_v = array()){// gestisce la prima...
<?php $arr_age = array(18, 20, 25); var_dump($arr_age); ?> 运行该例子输出: code array(3) { [0]=> int(18) [1]=> int(20) [2]=> int(25) } print_r() 和 var_dump() 函数一般是用于调试程序使用,更多情况是使用 echo 来输出具体的数组单元值。