一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

php數組總結篇(一)

數組
1.數組的下標是整型數值或者是字符串類型。
eg1.索引數組的鍵是______,關聯數組的鍵是______。
2.字符串作為索引的時候,應加上引號。常量或者變量不用加引號,否則無法編譯。
php中,沒有引號的字符串會自動生成一個裸字符串,而 php 可能會在以后定義此常量,不幸的是你的代碼中有同樣的名字,那么這個字符串就被重新賦值。
eg2.<?php
// 顯示所有錯誤
error_reporting(E_ALL);
$arr = array('fruit' => 'apple', 'veggie' => 'carrot');
// 正確
print $arr['fruit']; // apple
print $arr['veggie']; // carrot
// 不正確。This works but also throws a php error of
// level E_NOTICE because of an undefined constant named fruit
//
// Notice: Use of undefined constant fruit - assumed 'fruit' in...
print $arr[fruit]; // apple
// Let's define a constant to demonstrate what's going on. We
// will assign value 'veggie' to a constant named fruit.
define('fruit','veggie');
// Notice the difference now
print $arr['fruit']; // apple
print $arr[fruit]; // carrot
// The following is okay as it's inside a string. Constants are not
// looked for within strings so no E_NOTICE error here
print "Hello $arr[fruit]"; // Hello apple
// With one exception, braces surrounding arrays within strings
// allows constants to be looked for
print "Hello {$arr[fruit]}"; // Hello carrot
print "Hello {$arr['fruit']}"; // Hello apple
// This will not work, results in a parse error such as:
// Parse error: parse error, expecting T_STRING' or T_VARIABLE' or T_NUM_STRING'
// This of course applies to using autoglobals in strings as well
print "Hello $arr['fruit']";
print "Hello $_GET['foo']";
// Concatenation is another option
print "Hello " . $arr['fruit']; // Hello apple
?>
3.鍵值問題
$a['color'] = 'red';
$a['taste'] = 'sweet';
$a['shape'] = 'round';
$a['name'] = 'apple';
$a[] = 4; // key will be 0
$b[] = 'a'; // key will be 0
$b[] = 'b'; // key will be 1
$b[] = 'c'; // key will be 2
switching = array( 10, // key = 0
5 => 6,
3 => 7,
'a' => 4,
11, // key = 6 (maximum of integer-indices was 5)
'8' => 2, // key = 8 (integer!)
'02' => 77, // key = '02'
0 => 12 // the value 10 will be overwritten by 12
);
<?php
$multi_array = array("red",
"green",
42 => "blue","yellow" => array("apple",9 => "pear","banana","orange" => array("dog","cat","iguana")));
?>
A.$multi_array['yellow']['apple'][0]
B.$multi_array['blue'][0]['orange'][1]
C.$multi_array[3][3][2]
D.$multi_array['yellow']['orange']['cat']
E.$multi_array['yellow']['orange'][1]
--------------------------------待續待續待續------
4.array_walk
5.var_dump
6.array_intersect
7.array_sum
8.array_count_values
9.array_flip
10.natsort
11.ksort(),asort(),krsort(),sort(),usort()
12.array_reverse()
13.array_merge
14.reset
-------------------------------待續待續待續------
15.array_combine
16array_count_values
17.array_diff
18.array_filter
19.array_search

php技術php數組總結篇(一),轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 国语对白免费观看网址 | 黄网在线免费 | 亚洲第1页| 色欧美视频 | 中文字幕一区二区三区5566 | 亚洲精品国产网红在线 | 天天色综 | 2022年国产精品久久久久 | 欧美人与zoxxxx视频 | 永久免费av网站 | 影音先锋在线亚洲精品推荐 | 欧美成人久久久 | 亚洲成人91 | 伊人久久亚洲综合 | 加勒比不卡 | 免费欧美黄色 | 欧美有码视频 | 丁香婷婷综合五月六月 | 久久手机免费视频 | 色综合久久加勒比高清88 | 一级做a爰片久久毛片16 | 欧美怡红院免费全视频 | 国产精品原创 | 青青草91视频 | 亚洲图片一区二区三区 | 韩国毛片 | 99精品视频在线观看免费播放 | 亚洲国产精品日韩一线满 | 免费的成人a视频在线观看 免费的黄色片视频 | 国产私拍福利精品视频网站 | 国产精品视频第二区第二页 | 露脸真实国产精品自在 | 久久精品爱国产免费久久 | 国产成人精品第一区二区 | 国产亚洲精品视频中文字幕 | 国产成人成人一区二区 | 国产成人午夜91精品麻豆剧场 | 91成人网| 色哟在线 | 亚洲精品日韩中文字幕久久久 | 国产免费成人在线视频 |