久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

多維數組 PHP 內爆

Multidimensional Array PHP Implode(多維數組 PHP 內爆)
本文介紹了多維數組 PHP 內爆的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

就我的數據結構而言,我有一個communications數組,每個communications_id本身包含三個信息:id、score和content.

In terms of my data structure, I have an array of communications, with each communications_id itself containing three pieces of information: id, score, and content.

我想內爆這個數組以獲得一個逗號分隔的 id 列表,我該怎么做?

I want to implode this array in order to get a comma separated list of ids, how do I do this?

推薦答案

PHP 5.5 更新

PHP 5.5 引入了 array_column 這是一整類 array_map 用法的便捷快捷方式;這里也適用.

Update for PHP 5.5

PHP 5.5 introduces array_column which is a convenient shortcut to a whole class of array_map usage; it is also applicable here.

$ids = array_column($communications, 'id');
$output = implode(',', $ids);

原答案

您需要從您的通信數組中制作一個僅包含 id 的數組.那么內爆將是微不足道的.

Original answer

You need to make an array of just ids out of your array of communications. Then the implode would be trivial.

提示:該函數是array_map.

解決方案:

假設為 PHP 5.3,否則您必須將回調編寫為字符串.

Assumes PHP 5.3, otherwise you 'd have to write the callback as a string.

$ids = array_map(function($item) { return $item['id']; }, $communications);
$output = implode(',', $ids);

這篇關于多維數組 PHP 內爆的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Joining 2 tables in SELECT(MYSQL/PHP)(在 SELECT(MYSQL/PHP) 中加入 2 個表)
How to make lt;option selected=quot;selectedquot;gt; set by MySQL and PHP?(如何使lt;option selected=“selectedgt;由 MySQL 和 PHP 設置?)
Auto populate a select box using an array in PHP(使用 PHP 中的數組自動填充選擇框)
PHP SQL SELECT where like search item with multiple words(PHP SQL SELECT where like search item with multiple words)
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT(json_encode 從 MSSQL-SELECT 產生 JSON_ERROR_UTF8)
MySQL ORDER BY rand(), name ASC(MySQL ORDER BY rand(),名稱 ASC)
主站蜘蛛池模板: www.久久久久久 | 在线亚洲天堂 | 国产精品久久久久久无人区 | 日韩欧美国产成人 | 欧美爱爱网 | 亚洲一区精品视频 | 欧美综合一区 | 综合色婷婷一区二区亚洲欧美国产 | 亚洲精品国产精品国自产观看浪潮 | 一级毛片黄色 | 日韩黄色小视频 | 日产av在线 | 日韩在线观看中文字幕 | 91欧美激情一区二区三区成人 | 亚洲天堂一区 | 欧美日韩免费在线 | 欧美黄色一级 | 国产精品羞羞答答 | 日韩在线观看 | 伊人久久av| 天天干天天爽 | 毛片网站在线播放 | 亚洲爱爱网 | 中文字幕中文字幕 | 亚洲aaaaaa| 伊人网视频| 91超碰人人 | 亚洲三级在线播放 | 超碰成人免费 | 就爱啪啪网 | 黑人巨大猛烈捣出白浆 | 草少妇| 91精品久久久久久 | 国产69精品久久久久久 | 丰满少妇高潮在线观看 | 波多野结衣一区二区 | 国产成人精品网站 | 国产精品久久午夜夜伦鲁鲁 | 国产综合亚洲精品一区二 | 欧美日韩一区在线 | 日韩中文字幕在线播放 |