字符串转换为数组
<?php
$value1 = "Hello, world";
$convert = explode(" ",$value1);
echo $convert[1]; //Hello
echo $convert[2]; //world
// i convert particular number of array to string
$s = implode(" ", $convert[2]);
?>
我想要输出:world
但是我收到此错误消息:
错误: 警告:implode():在
中传递的参数无效
我试过,但没有做任何帮助
答案 0 :(得分:1)
如果您只想要输出world
,那么这应该有效:
<?php
$value1 = "Hello, world";
$convert = explode(", ",$value1);
//echo $convert[0]; //Hello
echo $convert[1]; //world
?>