Php array, modification, traversal, function, etc.
Last Update:2014-05-14
Source: Internet
Author: User
Php array format: ①, numeric array form: array (v1, v2, v3, v4 ,.....) array (value 1, value 2, value 3, & hellip;) ②, associated array form such as: array (k1 = & gt; v1, k2 = & gt; v2, k3 = & gt; v3 ,.......) array (key 1 = & gt; value 1, key 2 = & gt; value 2, key 3 = & gt php array format: ①, the value array is like: array (v1, v2, v3, v4 ,.....) array (value 1, value 2, value 3 ,......) ② Join array, for example, array (k1 => v1, k2 => v2, k3 => v3 ,.......) array (key 1 => value 1, key 2 => value 2, key 3 => value 3 ,......) ③ Multi-dimensional data $ arr_arr = array (4567, 77.7, 99,100), "aa", "bb", cc); Data Display: print_r () var_dump () (including the type and length information) $ arr = array (, 5); print_r ($ arr); echo"
"; Var_dump ($ arr); the result is: array ([0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5) array (5) {[0] => int (1) [1] => int (2) [2] => int (3) [3] => int (4) [4] => int (5)} array traversal foreach (): $ arr = array (1, 2, 3, 4, 5 ); foreach ($ arr as $ k =>$ v) {echo "key => value is ". $ k. "=> ". $ v."
";} Multi-dimensional array output: $ arr_arr = array (4567, 77.7, 99,100)," aa "," bb ", cc); echo" var_dump multi-dimensional array
"; Var_dump ($ arr_arr); echo" print_r () multi-dimensional array
"; Print_r ($ arr_arr); display: var_dump multi-dimensional array (4) {[0] => array (4) {[0] => int (4567) [1] => float (77.7) [2] => int (99) [3] => int (100)} [1] => string (2) "aa" [2] => string (2) "bb" [3] => string (2) "cc"} print_r () multi-dimensional Array ([0] => Array ([0] => 4567 [1] => 77.7 [2] => 99 [3] => 100) [1] => aa [2] => bb [3] => cc) array function: delete function: unset ($ arr ['K']); value sorting: sort (), rsort () (reverse) key sorting: ksort (), krsort () sum: array_sum ($ array) count: count () <----> sizeof () search: in_array (value, $ array) array_search (value, $ array) first look at the W3Cschool, paste a directory, and get familiar with the learning plan: 1, php Basics PHP tutorials PHP introduction PHP installation PHP syntax PHP variable PHP string PHP operator PHP If... elsePHP SwitchPHP array PHP loop PHP function PHP form PHP $ _ GETPHP $ _ POST 2, php advanced PHP date PHP shortdephp file PHP file Upload PHP CookiesPHP SessionsPHP E-mailPHP security E-mailPHP ErrorPHP ExceptionPHP Filter III, php database PHP database MySQL introduction MySQL ConnectMySQL CreateMySQL InsertMySQL SelecthMySQL WhereMySQL Order ByMySQL UpdateMySQL DeletePHP ODBC 4, php and xmlPHP XMLXML Expat ParserXML DOMXML SimpleXML 5, introduction to php, ajaxPHP, and AJAXAJAX XMLHttpRequestAJAX SuggestAJAX xmlaajax DatabaseAJAX responsexmlaajax Live SearchAJAX RSS ReaderAJAX Poll