while($row = mysql_fetch_array($result))
目前我的$row['content']里面有四个字符串,我怎样才能将它们放入数组中的单独对象中?
如 0>"第一个字符串">
1>"第二串"等。。。
目前它们似乎都捆绑在一起......但是我需要将它们分隔在一个数组中。
我是PHP的新手,花了很长时间试图找出如何做到这一点。
提前谢谢。
print_r($row["内容"](;
返回:
你好世界!另一个和另一个...更多即将推出...
$row返回的 var 转储:
array(4( { [0]=> string(1( "1" ["id"]=> string(1( "1" [1]=> string(12( "hello world!"["内容"]=> 字符串(12( "你好世界!" }array(4( { [0]=> string(1( "2" ["id"]=> string(1( "2" [1]=> string(11( "Another one" ["content"]=> string(11( "Another one" } array(4( { [0]=> string(1( "3" ["id"]=> string(1( "3" [1]=> string(18( "and other one..."["内容"]=> 字符串(18( "还有一个..." }array(4( { [0]=> string(1( "4" ["id"]=> string(1( "4" [1]=> string(14( "More Comeing..."["内容"]=> 字符串(14( "更多即将到来..." }
TRY
while($row = mysql_fetch_array($result))
{
$output[] = $row['content'];
}
echo "<pre>";
print_r($output);
编辑:我看错了,对不起。如果您的字符串用逗号分隔,那么这就足够了:
$array = explode(',', $row['content']);