如何从PHP数组的元素中获取单词并将它们添加到数组的末尾
示例:我有这个数组
阵 ( [0] => SQL [1] =>神谕 [2] =>数据库 [4] => bd下载 [5] =>教程 )
我想要
阵 ( [0] => SQL [1] =>神谕 [2] =>数据 [4] => BD [5] =>教程 [6] =>基地 [7] =>下载 )
答案 0 :(得分:1)
$data = array('sql', 'oracle', 'data bases', 'bd download', 'tutorial');
$allWords = array();
array_walk(
$data,
function($value) use (&$allWords) {
$allWords = array_merge($allWords, explode(' ', $value));
}
);
var_dump($allWords);
答案 1 :(得分:0)
试试这个:
$raw = array('sql', 'oracle', 'data bases', 'bd download', 'tutorial');
$imploded = implode(' ', $raw);
$usable = explode(' ', $imploded);
var_dump($usable);