<?php// 格式: 【二維數組】 Array ( ? ?[0] => Array ? ? ? ?( ? ? ? ? ? ?[topicid] => 1 ? ? ? ?) ? ?[1] => Array ? ? ? ?( ? ? ? ? ? ?[topicid] => 2 ? ? ? ?) ? ?[2] => Array ? ? ? ?( ? ? ? ? ? ?[topicid] => 6 ? ? ? ?) )//方法一:$topicid = ' '; //變量賦值為空//用foreach 遍歷下二維數組foreach($arrs as $key=>$vals){ ????$topicid.=$vals['topicid'].',';}// 使用 rtrim() 函數從字符串右端刪除字符:$topicid = rtrim($topicid, ',');echo $topicid;//====================================結果: 1,2,6// 方法二:foreach($ProTopicid as $valueId){ ????$string ?= ''; ????foreach($valueId as $v){ ????????$string.= rtrim($v.','); ????}}
- 1 回答
- 0 關注
- 6008 瀏覽
添加回答
舉報
0/150
提交
取消