将数组转换为字符串

Jay*_*ayu 2 php arrays string

可能重复:
将PHP数组字符串转换为数组

哪个函数可用于将数组转换为字符串,从而保持将字符串返回数组的能力?

Gum*_*mbo 7

serialize函数将任何值转换为字符串.


spa*_*pas 7

您可以使用该implode()函数将数组转换为字符串:

$array = implode(" ", $string); //space as glue
Run Code Online (Sandbox Code Playgroud)

如果要将其转换回数组,可以使用explode函数:

$string = explode(" ", $array); //space as delimiter
Run Code Online (Sandbox Code Playgroud)

  • 如果$ array [2] =="有些价值"? (2认同)