php5.5新數(shù)組函數(shù)array_column使用(2)_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:PHP preg_match的匹配多國(guó)語言的技巧這篇文章主要是介紹了PHP preg_match中匹配多國(guó)語言的方法,需要的朋友可以參考下 正則:[\S]{2,32} 過濾是管用的 PHP中: 復(fù)制代碼 代碼如下: ?php var_dump( preg_match(/[\S\b]{2,32}/,'') ); echo 'hr /'; var_dump( preg_match(/[\S\b]{2,32}/,'中國(guó)') ); 是不行的
array_column 用于獲取二維數(shù)組中的元素(PHP 5 >= 5.5.0)
<?php
// Array representing a possible record set returned from a database
$records = array(
array(
'id' => 2135,
'first_name' => 'John',
'last_name' => 'Doe',
),
array(
'id' => 3245,
'first_name' => 'Sally',
'last_name' => 'Smith',
),
array(
'id' => 5342,
'first_name' => 'Jane',
'last_name' => 'Jones',
),
array(
'id' => 5623,
'first_name' => 'Peter',
'last_name' => 'Doe',
)
);
$first_names = array_column($records, 'first_name');
print_r($first_names);
?>
Array
(
[0] => John
[1] => Sally
[2] => Jane
[3] => Peter
)<?php
// Using the $records array from Example #1
$last_names = array_column($records, 'last_name', 'id');
print_r($last_names);
?>
Array
(
[2135] => Doe
[3245] => Smith
[5342] => Jones
[5623] => Doe
)
分享:php 中序列化和json使用介紹【序列化的概念】 序列化是將對(duì)象狀態(tài)轉(zhuǎn)換為可保持或可傳輸?shù)母袷降倪^程。與序列化相對(duì)的是反序列化,它將流轉(zhuǎn)換為對(duì)象。這兩個(gè)過程結(jié)合起來,可以輕松地存儲(chǔ)和傳輸數(shù)據(jù)。 將對(duì)象的狀態(tài)信息轉(zhuǎn)換為可以存儲(chǔ)或傳輸?shù)拇绑w的過程。 在序列化期間,對(duì)象將其當(dāng)前狀態(tài)寫入到臨
相關(guān)PHP教程:
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁面代碼執(zhí)行時(shí)間
- PHP中獎(jiǎng)概率的抽獎(jiǎng)算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對(duì)圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運(yùn)算符優(yōu)先級(jí)介紹
- 關(guān)于PHP語言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- PHP preg_match的匹配多國(guó)語言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 解析將多維數(shù)組轉(zhuǎn)換為支持curl提交的一維數(shù)組格式
PHP教程Rss訂閱編程教程搜索
PHP教程推薦
- 《PHP設(shè)計(jì)模式介紹》第五章 注冊(cè)模式
- 如何成為PHP高手
- php4和php5單態(tài)模式(Singleton Pattern)寫法
- 揭秘PHP+MySQL動(dòng)態(tài)網(wǎng)站開發(fā)基礎(chǔ)實(shí)例教程
- 基于PHP選項(xiàng)與信息函數(shù)的使用詳解
- PHP register_shutdown_function函數(shù)的深入解析
- 利用PHP的OOP特性實(shí)現(xiàn)數(shù)據(jù)保護(hù)
- PHP技巧:用PHP導(dǎo)出MySQL數(shù)據(jù)庫內(nèi)容為.sql文件
- 基于AppServ,XAMPP,WAMP配置php.ini去掉警告信息(NOTICE)的方法詳解
- PHP進(jìn)階技巧:php用流方式制作縮略圖
- 相關(guān)鏈接:
- 教程說明:
PHP教程-php5.5新數(shù)組函數(shù)array_column使用(2)
。