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

Dreamweaver Mac version
Visual web development tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Chinese version
Chinese version, very easy to use

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software
