将$result解析为$item以分离PHP值
我从数据库查询中得到了一些值,这些值都是连接在一起的将$result解析为$item以分离PHP值,php,drupal,drupal-7,Php,Drupal,Drupal 7,我从数据库查询中得到了一些值,这些值都是连接在一起的 foreach($result as $item) { print $item->chvotes; } 输出是来自Drupal轮询的投票序列,因此示例输出可能是1020340312 投票地点(例如) 1020340212 我必须将它们放入一系列单独的php变量中,以便在其他地方使用。 我使用的查询是: $result = db_select('poll_choice','n') ->fields('n',array('c
foreach($result as $item) {
print $item->chvotes;
}
输出是来自Drupal轮询的投票序列,因此示例输出可能是1020340312
投票地点(例如)
1020340212
我必须将它们放入一系列单独的php变量中,以便在其他地方使用。
我使用的查询是:
$result = db_select('poll_choice','n')
->fields('n',array('chvotes'))
->range(0,12)
->condition('n.nid',$nid,'=')
->execute();
让我们假设您的值由逗号分隔<代码>,
$values = array();
foreach($result as $item) {
$values[] = explode(',', $item->chvotes);
}
$values
将是一个包含分隔值的数组。需要更多信息,一些数据如何。