1. Structure of the output array: bool Print_r (array);
$arr=array(' Jack ', ' Mike ', ' Tom '); Print_r ($arr); //
2. How do I declare a two-bit array?
$arr=array(' name ' = =array(' Jack ', ' Mike '), ' sex ' = =array(' Man ', ' woman ') )); Print_r ($arr); // Array ([name] = = Array ([0] = + Jack [1] = Mike) [sex] = = Array ([0] = man [1] = = woman))
3. Traversal array The Foreach method is described in the third section of the 8th Stem of PHP: http://www.cnblogs.com/JhoneLee/p/3773616.html
4. String variable groups: Array explode (string boundary, string converted string, integer array max element Upper)
$arr =explode (' A ', $str ); print_r ( $arr ); // Remove the array as a boundary of a group of//array ([0] = [1] = = BH [2] = = BS [3] = b [4] => ; FB [5] = db [6] = b [7] = CB [8] = =/----------------------------------------------------- $arr =explode (' A ', $str , 3); print_r ( $arr ); // Removes the array as a boundary, but because the upper limit is set, the last string is no longer split//array ([0] = [1] = BH [2] = BSABAFBADBA BACBA)
5. Change the array to a string: string implode (string delimiter, array is transformed);
$arr 2=array(' Jack ', ' Mike ', ' Tom '); $arr=array(' name ' = = 'array(' Jack ', ' Mike ', ' Tom '), ' sex ' = =array(' Male ', ' female ') )); $str=implode(' ¥ ',$arr 2); // Jack¥mike¥tom $str=implode(' ¥ ',$arr); // Two-dimensional array error
6. Number of statistics arrays: count (array is counted, whether recursive (1: Yes, others: not));
$arr 2=Array(' Jack ', ' Mike ', ' Tom ');$arr=Array(' name ' = =Array(' Jack ', ' Mike ', ' Tom '), ' sex ' =Array(' Man ' =Array(' true ', ' false '), ' woman '));Echo Count($arr 2);//3Echo Count($arr);//2Echo Count($arr, 1);//9 Recursive statistics the number of multidimensional arrays here can only be 1, for other integers can only be recursive statistics
7. Retrieve the position of the value in the array: Array_search (check, array checked, check type);
$arr 2=Array(' Jack ', ' Mike ', ' Tom ', 1);$arr=Array(' name ' = ' Jack ', ' sex ' = ' male ');Echo Array_search(' 1 ',$arr 2);//3Echo Array_search(' 1 ',$arr 2,TRUE);//not displayed because the type is not correctEcho Array_search(' Jack ',$arr);//name//multidimensional array can only search arrays