Array Analysis of Common PHP Development Functions [Unfinished]_PHP Tutorial
WBOYOriginal
2016-07-21 15:17:09959browse
1. Array processing functions: Drunk feeling: Array processing functions are very common in PHP development, and it is crucial to learn array processing functions well. In practical applications, array processing functions involve: the creation of arrays, and the conversion of strings into arrays. Mutual conversion, array to XML, array to JSON. Array detection. Array merging and splitting. Number of arrays. Get all values in the array, get all key values in the array [subscript] 1. Create an array : $new = array(); 2. implode (separated, str) concatenates array value data according to specified characters
3.count(arr) Count the number of cells in the array or the number of attributes in the object 4.is_array(arr) Check whether the variable Is an array 5.array_rand() function randomly selects one or more elements from the array and returns it.
function array2xml($array, $tag) { function ia2xml($array) { $xml=""; foreach ($array as $key=>$value) { if (is_array($value)) { $xml.="<$key>".ia2xml($value)."$key>"; } else { $xml.="<$key>". $value."$key>"; } } return $xml; } return simplexml_load_string("<$tag>".ia2xml($array) ."$tag>"); } $test['type']='lunch'; $test['time']='12:30'; $test['menu']=array('entree'=>'salad', 'maincourse'=>'steak'); echo array2xml($test,"meal")->asXML() ;
Output:
Copy code The code is as follows:
lunch
http://www.bkjia.com/PHPjc/325799.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325799.htmlTechArticle1. Array processing functions: Drunk feeling: Array processing functions are very common in PHP development. Learn array processing functions well. It is crucial. In practical applications, array processing functions involve: the creation of arrays...
Statement:
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