php数组,批改,遍历,函数等
php数组,修改,遍历,函数等
php W3c http://www.w3school.com.cn/php/func_array_search.asp
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 Include
- PHP 文件
- PHP 文件上传
- PHP Cookies
- PHP Sessions
- PHP E-mail
- PHP 安全 E-mail
- PHP Error
- PHP Exception
- PHP Filter
PHP 数据库
- MySQL 简介
- MySQL Connect
- MySQL Create
- MySQL Insert
- MySQL Selecth
- MySQL Where
- MySQL Order By
- MySQL Update
- MySQL Delete
- PHP ODBC
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
六,php参考手册
PHP 参考手册
- PHP Array
- PHP Calendar
- PHP Date
- PHP Directory
- PHP Error
- PHP Filesystem
- PHP Filter
- PHP FTP
- PHP HTTP
- PHP LibXML
- PHP Mail
- PHP Math
- PHP MySQL
- PHP SimpleXML
- PHP String
- PHP XML
- PHP Zip
- PHP 杂项

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

AI Hentai Generator
Generate AI Hentai for free.

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

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
