PHP中字符串的数组键值 [英] Array key value to string in PHP

查看:33
本文介绍了PHP中字符串的数组键值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想转换这种风格的数组:

I want to convert an array of this style:

Array ( [0] => Array ( [post_id] => 20752 ) [1] => Array ( [post_id] => 20753 ) ) 

进入字符串:

20752, 20753

我该怎么做?

推荐答案

你可以使用 PHP array_column 函数结合 <代码>内爆:

You can use PHP array_column function with combination of implode:

implode(', ', array_column($data, 'post_id'));

这篇关于PHP中字符串的数组键值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆