Home > Article > Backend Development > PHP Basics 1: Arrays and Data Structures
The content introduced in this article is about the basics of php, which has a certain reference value. Now I share it with everyone. Friends in need can refer to it
<!-- PHP数组与数据结构 --> <?php // // $arr = array('欢迎',10 => '学习', // // 'php', // // 19 => '语言','相信自己一定能学会' // // ); // // $arr = array('刘亦菲', // // 'anglebaby','鹿晗','范彬彬' // // ); // $arr[0] = '北京'; // $arr[1] = '上海'; // $arr[2] = '广州'; // $arr = array('0' => '小明', // '1' => '小龙', // '2' => '小花', // '3' => '小兰' // ); // $arr = [ // ['南宁','崇左','凭祥','桂林','百色'], // ['龙州','武鸣','宁明','大兴','苹果'] // ]; // $arr = array( // array('南宁','崇左','凭祥','桂林','百色'), // array('龙州','武鸣','宁明','大兴','苹果') // ); // echo '<pre class="brush:php;toolbar:false">'; // echo count($arr);die; // var_dump($arr[2]); // echo ''; ?> '; } unset($num[1]); var_dump($num); $name = array( 'name1' => '芙蓉', 'name2' => '凤姐' ); foreach ($name as $key => $value){ echo $key.'——————'.$value.'
'; var_dump($date); echo '<pre class="brush:php;toolbar:false">'; list($one,$two) = each($kongjie); echo $one.'-'.$two.'<br />'; $minggren = array("邓超","黄晓明","泞泽涛","钟汉良"); $dc = array_shift($minggren); array_unshift($array, $value1); array_push($array, $value1); array_pop($array); current($array); key($array); next($array); prev($array); reset($array); end($array); print_r($minggren); //php数组常用函数 array_combine($keys, $values); range($start, $end); compact($varname1); array_fill($start_index, $num, $value); array_chunk($array, $size); array_merge($array1); array_slice($array, $offset); array_diff($array1, $array2); array_search($needle, $haystack); array_splice($input, $offset); array_sum($array); in_array($needle, $haystack); array_key_exists($key, $array); shuffle($array); count($array_or_countable); array_flip($array); array_keys($array); array_values($array); array_reverse($array); array_count_values($array); array_rand($array); array_unique($array); sort($array); rsort($array); asort($array); arsort($array); asort($array); arsort($array); ksort($array); krsort($array); natsort($array); natcasesort($array); array_filter($array); extract($array); ?>
The above is the detailed content of PHP Basics 1: Arrays and Data Structures. For more information, please follow other related articles on the PHP Chinese website!