Php 仅从数组\列数组返回中提取字符串
我已经听说过很多次了,如果有一个新问题,即使是在同一个代码上,也要创建一个新线程,那么我就在这里。感谢大家帮我回答上一个问题 我有以下代码:Php 仅从数组\列数组返回中提取字符串,php,arrays,Php,Arrays,我已经听说过很多次了,如果有一个新问题,即使是在同一个代码上,也要创建一个新线程,那么我就在这里。感谢大家帮我回答上一个问题 我有以下代码: /* Return an array of _octopus_ids */ $offices = array_map( function($post) { return array( 'id' => get_post_meta($post->ID, '_octopus_id', true),
/* Return an array of _octopus_ids */
$offices = array_map(
function($post) {
return array(
'id' => get_post_meta($post->ID, '_octopus_id', true),
);
},
$query->posts
);
/* Dump out all the multi-dimensional arrays */
var_dump($offices);
$test = array_column($offices, 'id');
var_dump($test);
var\u dump($offices)
转储以下内容:
var\u dump($test)
转储以下内容:
问题:
如何使用以下代码:
/* Return an array of _octopus_ids */
$offices = array_map(
function($post) {
return array(
'id' => get_post_meta($post->ID, '_octopus_id', true),
);
},
$query->posts
);
/* Dump out all the multi-dimensional arrays */
var_dump($offices);
$test = array_column($offices, 'id');
var_dump($test);
$results=$octopus->get_all('employees/”。$test;
,这会导致注意:数组到字符串的转换
错误
我希望能够进行这样的结果调用$results=$octopus->get_all('employees/1382');
-因此我只希望将$test的数字字符串附加到employees的末尾/
如果我在employees/之后硬编码1382,我会得到以下结果:
对象(stdClass)[1325]
公共“id”=>int1382
将字符串数组转换为字符串的正确方法是什么
array (size=10)
0 => string '1382' (length=4)
1 => string '1330' (length=4)