foreach($categories as $category) { print_r($category); }
上面的代码给出了以下结果.
stdClass Object ( [category_Id] => 4 [category_Title] => cat 4 ) stdClass Object ( [category_Id] => 7 [category_Title] => cat 7 ) stdClass Object ( [category_Id] => 6 [category_Title] => cat 6 )
如何使用implode(‘,’)获得以下结果:
cat 4,cat 7,cat 6
我用过它,但是我收到了一个错误
试试吧
原文链接:https://www.f2er.com/php/136873.htmlforeach($categories as $category) { $new_arr[] = $category->category_Title; } $res_arr = implode(',',$new_arr); print_r($res_arr);