PHP array, modification, traversal, function, etc._PHP tutorial

WBOY
Release: 2016-07-14 10:08:46
Original
940 people have browsed it

The form of php array:

①, numerical array
Form: array(v1,v2,v3,v4,...)
array (value 1, value 2, value 3, ...)
②, associative array
The shape is: array(k1=>v1,k2=>v2,k3=>v3,....)
array(key1=>value1, key2=>value2, key3=>value3,…)
③, multi-dimensional data
$arr_arr = array(array(4567,77.7,99,100),"aa","bb",cc);
Data display:
print_r()
var_dump() (contains type, length and other information)
$arr = array(1,2,3,4,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."
";
}
Output of multidimensional array:
$arr_arr = array(array(4567,77.7,99,100),"aa","bb",cc);
echo "var_dump multidimensional array
";
var_dump($arr_arr);
echo "print_r() multidimensional array
";
print_r($arr_arr);
Display:
var_dump multidimensional array
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() multidimensional array
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 order)
Key sorting: ksort(), krsort()
Sum: array_sum($array)
Number: count()<---->sizeof()
Find: in_array(value,$array)
array_search(value,$array)
Hey, let’s take a look at W3Cschool first, post a table of contents, start a study plan, and get familiar with it:
1, PHP basics
PHP Basics
PHP Tutorial
Introduction to PHP
PHP installation
PHP syntax
PHP Variables
PHP string
PHP Operators
PHP If...Else
PHP Switch
PHP Array
PHP Loop
PHP functions
PHP Form
PHP $_GET
PHP $_POST
2, php advanced
PHP Advanced
PHP Date
PHP Include
PHP File
PHP file upload
PHP Cookies
PHP Sessions
PHP E-mail
PHP Secure E-mail
PHP Error
PHP Exception
PHP Filter
Three, php database
PHP Database
Introduction to MySQL
MySQL Connect
MySQL Create
MySQL Insert
MySQL Sele
MySQL Where
MySQL Order By
MySQL Update
MySQL Delete
PHP ODBC
Four, php and xml
PHP XML
XML Expat Parser
XML DOM
XML SimpleXML
Five, php and ajax
PHP and AJAX
Introduction to AJAX
XMLHttpRequest
AJAX Suggest
AJAX XML
AJAX Database
AJAX responseXML
AJAX Live Search
AJAX RSS Reader
AJAX Poll

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477763.htmlTechArticleThe form of php array: ①, the numerical array is in the form: array(v1,v2,v3,v4,.. ...) array (value 1, value 2, value 3, ) ②, the associative array is in the form: array(k1=v1,k2=v2,k3=v3,....) array (key 1= Value...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template