Table of Contents
PHP 基础
PHP 高级
PHP 数据库
PHP XML
PHP 和 AJAX
PHP 参考手册
Home Backend Development PHP Tutorial php数组,批改,遍历,函数等

php数组,批改,遍历,函数等

Jun 13, 2016 pm 12:53 PM
array gt nbsp php quot

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 日期
  • 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

六,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 杂项


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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

CakePHP Project Configuration CakePHP Project Configuration Sep 10, 2024 pm 05:25 PM

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

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

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

CakePHP Date and Time CakePHP Date and Time Sep 10, 2024 pm 05:27 PM

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

CakePHP File upload CakePHP File upload Sep 10, 2024 pm 05:27 PM

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

CakePHP Routing CakePHP Routing Sep 10, 2024 pm 05:25 PM

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

Discuss CakePHP Discuss CakePHP Sep 10, 2024 pm 05:28 PM

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

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

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

CakePHP Creating Validators CakePHP Creating Validators Sep 10, 2024 pm 05:26 PM

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

See all articles