在PHP中打破字段和数据

时间:2014-09-17 09:12:56

标签: php mysql

enter image description here

我想知道如何从标记字段中断数据:

produk
test
murah
modem

当以逗号分隔

时,它会破坏记录中的数据

由于

3 个答案:

答案 0 :(得分:2)

让您从表中获取数据,然后在while loop中执行。请忽略mysql_*,它也可能是mysqli_* -

$tags = array();
while($res = mysql_fetch_object($rec)) {
    $tags = array_merge($tags, explode(',', $res->tag)); 
}

答案 1 :(得分:0)

使用php查询列,

然后使用PHP的explode方法

来自docs示例:

$res  = "produk,test,murah,modem";
$res = explode(",", $res);
echo $res[0]; // produk
echo $res[1]; // test

答案 2 :(得分:0)

您要找的是explode()

http://php.net/manual/en/function.explode.php

它看起来像这样:

<?php
    //query goes here

   $values = explode(",",$row['tag']);
?>