且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP JSON特定于数组的键

更新时间:2023-02-23 08:14:22

只需使用php函数

just use php function array_column() like this :

array array_column(array $ input,混合$ column_key [,混合 $ index_key = null])

array array_column ( array $input , mixed $column_key [, mixed $index_key = null ] )

array_column()返回输入的单个列中的值, 由column_key标识.

array_column() returns the values from a single column of the input, identified by the column_key.

输入:一个多维数组或对象数组,可从中提取一列值.

input : A multi-dimensional array or an array of objects from which to pull a column of values from.

column_key :要返回的值列.此值可以是您要检索的列的整数键,也可以是关联数组或属性名称的字符串键名.

column_key : The column of values to return. This value may be an integer key of the column you wish to retrieve, or it may be a string key name for an associative array or property name.

$arr = json_decode($jsonResponse, true);
$selectionIds = array_column($records, 'selectionId');