This article is a mirror article of machine translation, please click here to jump to the original article.

View: 6988|Reply: 1

php arrays, modifications, traversals, functions, etc_PHP tutorials

[Copy link]
Posted on 8/7/2019 6:06:34 AM | | |
php array form:
(1), numerical array
Shape: array(v1, v2, v3, v4,.....)
array(value 1, value 2, value 3, ...... )
(2) Associative arrays
For example: array(k1=>v1,k2=>v2,k3=>v3,.......)
array(key 1 = > value 1, key 2 = > value 2, key 3 = > value 3,...... )
(3), multi-dimensional data
$arr_arr = array(array(4567,77.7,99,100),"aa","bb",cc);

Data display:
print_r()
var_dump() (contains information such as type, length, etc.)
$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)}
Traversal of the array foreach ():
$arr = array(1,2,3,4,5);

foreach($arr as $k => $v){
echo "key => value is ".$k." =>".$v."
";
}
Output of a multidimensional array:
$arr_arr = array(array(4567,77.7,99,100),"aa","bb",cc);
echo "var_dump multidimensional arrays
";
var_dump($arr_arr);
echo "print_r() multidimensional array
";
print_r($arr_arr);
Display:
var_dump Multidimensional arrays
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 functions:
delete function: unset($arr['k']);
Value sort: sort(), rsort() (reverse)
Key sort: ksort(), krsort()
Sum: array_sum ($array)
Number:count()sizeof()
Lookup: in_array(value,$array)
           array_search(value,$array)
Hey, take a look at W3Cschool first, post a catalog, start a study plan, and familiarize yourself with it:
1. PHP basics
PHP Basics
PHP tutorials
Introduction to PHP
PHP installation
PHP syntax
PHP variables
PHP strings
PHP operators
PHP If... Else
PHP Switch
PHP arrays
PHP loop
PHP functions
PHP forms
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
3. PHP database
PHP database
Introduction to MySQL
MySQL Connect
MySQL Create
MySQL Insert
MySQL Selecth
MySQL Where
MySQL Order By
MySQL Update
MySQL Delete
PHP ODBC
Fourth, php and XML
PHP XML
XML Expat Parser
XML DOM
XML SimpleXML

5. 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





Previous:watchOS 5.3 system update too slow solution
Next:What editor is used in the movie "The Fifth Estate"?
Posted on 8/7/2019 8:30:11 AM |
The tutorial of php100 that I learned before
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com