Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP$行到数组_Php - Fatal编程技术网

PHP$行到数组

PHP$行到数组,php,Php,目前,我的$row['content']中有四个字符串,如何将它们放入数组中的不同对象中 与0>中的“第一个字符串”相同 1>“第二个字符串” 等等 目前,他们都被捆绑成一个似乎。。。但我需要把它们分开排列 我是PHP新手,花了很长时间试图找到如何做到这一点 提前谢谢 打印($row['content']) 返回: 你好,世界!又一个又一个…更多的来了 $row返回的var转储: 数组(4){[0]=>string(1)“1”[“id”]=>string(1)“1”[1]=>string(12)

目前,我的$row['content']中有四个字符串,如何将它们放入数组中的不同对象中

与0>中的“第一个字符串”相同

1>“第二个字符串” 等等

目前,他们都被捆绑成一个似乎。。。但我需要把它们分开排列

我是PHP新手,花了很长时间试图找到如何做到这一点

提前谢谢

打印($row['content'])

返回:

你好,世界!又一个又一个…更多的来了

$row返回的var转储:

数组(4){[0]=>string(1)“1”[“id”]=>string(1)“1”[1]=>string(12)“hello world!”[“content”]=>string(12)“hello world!”}数组(4){[0]=>string(1)“2”[“id”]=>string(1)“2”[1]=>string(11)“另一个”[“content”=>string(11)“另一个”}数组(4){[0]=>string(1)“3”[“id”=>string(1)”3”=>[“内容”]=>string(18)”和另一个…}数组(4){[0]=>string(1)“4”[“id”]=>string(1)“4”[1]=>string(14)“更多…”[“内容”]=>string(14)“更多…”

试试看

while($row = mysql_fetch_array($result))
while($row=mysql\u fetch\u array($result))
{
$output[]=$row['content'];
}
回声“;
打印(输出);

编辑:对不起,我看错了。如果字符串用逗号分隔,那么这就足够了:

$array = explode(',', $row['content']);

var\u dump($row)
显示了什么?
explode(“\n”,$row['contents'))
?请您添加一些关于db模式的信息好吗?这4个字符串的分隔符是什么?我想根本没有分隔符。干杯。没有分隔符,您如何区分有4个字符串?因为它是从一个数据库中提取的,我有四个单独的条目,它会将它们捆绑在一起,以实现某种目的son.您在检索时使用哪个mySQL函数来构建它们?
CONCAT
应该有,可能是space@diEcho:你说得对,对不起。你能提供一些关于数据如何放入数据库的更多信息吗?这个问题只解决了(我想)当我们知道有什么样的数据时。如果你,作为一个人,不能分离字符串,那么计算机肯定不能:)
$array = explode(',', $row['content']);