我有这样一个数组
array (size=1)
45 =>
object(stdClass)[37]
public 'term_id' => string '45' (length=2)
public 'name' => string 'Appointments' (length=12)
public 'slug' => string 'appointments' (length=12)
public 'term_group' => string '0' (length=1)
public 'term_taxonomy_id' => string '48' (length=2)
public 'taxonomy' => string 'tribe_events_cat' (length=16)
public 'description' => string '' (length=0)
public 'parent' => string '0' (length=1)
public 'count' => string '1' (length=1)
public 'object_id' => string '625' (length=3)
46 =>
object(stdClass)[37]
public 'term_id' => string '46' (length=2)
public 'name' => string 'Appointmentx' (length=12)
public 'slug' => string 'appointmentx' (length=12)
public 'term_group' => string '0' (length=1)
public 'term_taxonomy_id' => string '48' (length=2)
public 'taxonomy' => string 'tribe_events_cat' (length=16)
public 'description' => string '' (length=0)
public 'parent' => string '0' (length=1)
public 'count' => string '1' (length=1)
public 'object_id' => string '626' (length=3)我只想从那个数组中去掉term_id,然后像这样merge
array(45,46,...);有人能帮我吗?
发布于 2013-07-24 18:20:01
因为键也包含ID,所以可以使用array_keys()。
$ids = array_keys($array);发布于 2013-07-24 18:18:45
$ids = array();
foreach($array as $object)
{
$ids[] = $object->termId;
}https://stackoverflow.com/questions/17841781
复制相似问题