逗号分隔列表在php

逗号分隔列表在php

本文介绍了逗号分隔列表在php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 我正在尝试建立一个逗号分隔的列表,应该是这样的(绿色,橙色,红色) $ I = 0; 
$ taxonomy = $ form_state [values] [taxonomy] [5];
foreach($ taxonomy as $ key => $ value){
$ result = db_query(SQL CODE goes here);
if(mysql_num_rows($ result)){
while($ i< mysql_num_rows($ result)){
$ resultset = db_fetch_array($ result);
$ comma_separated = implode(,,$ resultset);
$ i ++;
}
form_set_error(Date,t($ comma_separated。不能多次预订));
}


解决方案
  $结果集=阵列(); 
while($ data = db_fetch_array($ result)){
$ resultset [] = $ data;
}
$ comma_separated = implode(,,$ resultset);


I am trying to build a list separated by commas which should look like this (green, orange, red).

$i=0;
$taxonomy = $form_state[values][taxonomy][5];
foreach ($taxonomy as $key => $value){
  $result = db_query("SQL CODE goes here");
  if (mysql_num_rows($result)){
  while ($i<mysql_num_rows($result)){
    $resultset = db_fetch_array($result);
    $comma_separated = implode(",", $resultset);
    $i++;
  }
  form_set_error("Date", t("$comma_separated. cannot be booked more than once "));
}
解决方案
$resultset=array();
while ($data = db_fetch_array($result)) {
    $resultset[] = $data;
}
$comma_separated = implode(",", $resultset);

这篇关于逗号分隔列表在php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 20:45