-3
我想在數組中使用foreach,並且此foreach使用數組。該代碼是在這裏:php在數組中使用foreach
$records["data"][] = array(
$id,
$value['name'],
foreach($kichen_organ as $x => $x_value){ if($value['organ']==$x) '<span class="badge badge-success">'echo $x_value;'</span>' },
$value['type'] ,
$value['name_responsible'] ,
$value['family_responsible'] ,
$value['office'],
$value['fax'],
$value['mobile']);
$ kichen_organ是另一個數組,我分析它是通過重命名$ X鍵和價值$ s_value 但我收到此錯誤:
syntax error, unexpected 'foreach' (T_FOREACH), expecting ')' in /var/www/html/...
什麼是使用的解決方案數組中的循環?
你可以在數組聲明之後向數組添加元素嗎? – Thamilan
這是什麼'echo $ x_value;' ,在foreach中,數組元素中的連接和foreach循環? – developerCK
@Thamilan我將它們添加到數組聲明中之後 –