php数组,修改,遍历,函数等
php数组的形式:
①,数值数组
形如:array(v1,v2,v3,v4,.....)
array(值1,值2,值3, ……)
②,关联数组
形如:array(k1=>v1,k2=>v2,k3=>v3,.......)
array(键1=>值1,键2=>值2,键3=>值3,……)
③,多维数据
$arr_arr = array(array(4567,77.7,99,100),"aa","bb",cc);
数据的显示:
print_r()
var_dump()(包含了类型,长度等信息)
$arr = array(1,2,3,4,5);
print_r($arr);
echo "
";
var_dump($arr);
结果是:
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)}
数组的遍历foreach():
$arr = array(1,2,3,4,5);
foreach($arr as $k => $v){
echo "key => value is ".$k."=>".$v."
";
}
多维数组的输出:
$arr_arr = array(array(4567,77.7,99,100),"aa","bb",cc);
echo "var_dump 多维数组
";
var_dump($arr_arr);
echo "print_r() 多维数组
";
print_r($arr_arr);
显示:
var_dump 多维数组
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() 多维数组
Array( [0] => Array ( [0] => 4567 [1] => 77.7 [2] => 99 [3] => 100 ) [1] => aa [2] => bb [3] => cc)
数组函数:
删除函数:unset($arr['k']);
值排序:sort(),rsort()(倒序)
键排序:ksort(),krsort()
求和:array_sum($array)
个数:count()sizeof()
查找:in_array(value,$array)
array_search(value,$array)
哎先看看W3Cschool上的,贴个目录,学习计划搞起来,熟悉一下吧:
一,php基础篇
PHP 基础
PHP 教程
PHP 简介
PHP 安装
PHP 语法
PHP 变量
PHP 字符串
PHP 运算符
PHP If...Else
PHP Switch
PHP 数组
PHP 循环
PHP 函数
PHP 表单
PHP $_GET
PHP $_POST
二,php高级
PHP 高级
PHP 日期
PHP Include
PHP 文件
PHP 文件上传
PHP Cookies
PHP Sessions
PHP E-mail
PHP 安全 E-mail
PHP Error
PHP Exception
PHP Filter
三,php数据库
PHP 数据库
MySQL 简介
MySQL Connect
MySQL Create
MySQL Insert
MySQL Selecth
MySQL Where
MySQL Order By
MySQL Update
MySQL Delete
PHP ODBC
四,php与xml
PHP XML
XML Expat Parser
XML DOM
XML SimpleXML
五,php与ajax
PHP 和 AJAX
AJAX 简介
XMLHttpRequest
AJAX Suggest
AJAX XML
AJAX Database
AJAX responseXML
AJAX Live Search
AJAX RSS Reader
AJAX Poll

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

In PHP8, match expressions are a new control structure that returns different results based on the value of the expression. 1) It is similar to a switch statement, but returns a value instead of an execution statement block. 2) The match expression is strictly compared (===), which improves security. 3) It avoids possible break omissions in switch statements and enhances the simplicity and readability of the code.

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.
