我有一个表,其中包含 id、name 等字段和 (1,"sony,nokia,htc"),(2,"sony")(3,"Samsung") 等值。我获取记录但我的逻辑比我的逻辑要长期望。如果名称包含“,”,我想爆炸并获取唯一记录。我的结果看起来像
Name array will be { 0 =>"sony",1=>"HTC",2=>"Nokia"}.My dummy logic is here (This is incomplete not working properly.)
<?php
$row = array("sony,htc,nokia","htc","sony");
foreach ($row as $key => $valuek) {
if(strpos($valuek['value'], ",") !== false)
{
$str[] = explode(",",$valuek['value'] )
?>
<option value="<?php echo $valuek['value']?>"><?php echo $valuek['value']?></option>
<?php
}
?>
<option value="<?php echo $valuek['value']?>"><?php echo $valuek['value']?></option>
<?php } $i++;}?>