Answer the question
In order to leave comments, you need to log in
How to pass multiple numbers to array through a variable?
there is a code:
foreach ($ids as $id){
$top_term = get_top_term( 'cat' , $id );
$toptermids_cars .= $top_term->term_id.', ';
}
echo $toptermids_cars; // выведет 11, 55, 97, 27, 25,
$array_toptermids_cars = array( $toptermids_cars ); // но в array передается как строка
Answer the question
In order to leave comments, you need to log in
$array_toptermids_cars = array();
foreach ($ids as $id) {
$top_term = get_top_term('cat', $id);
$array_toptermids_cars[] = $top_term->term_id;
}
var_dump($array_toptermids_cars);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question