我在Phoronix Test Suite中找到了这段代码:

$os_packages_to_install = explode(' ', implode(' ', $os_packages_to_install));

我以前见过,但我不认为这是重点。它是做什么的?

最佳答案

它将返回一个数组,但与$os_packages_to_install的区别在于,如果$os_packages_to_install的值包含一个空格,它也将被拆分。
所以:

["hjk jklj","jmmj","hl mh","hlm"]

Inplode给出:
"hjk jklj jmmj hl mh hlm

再次爆炸将给出:
["hjk","jklj","jmmj","hl","mh","hlm"]

10-02 04:20