Php 在添加到数组之前拆分字符串

Php 在添加到数组之前拆分字符串,php,arrays,Php,Arrays,我正在提取一些文本并将其添加到数组中,如下所示: foreach($getthesp2 as $thesp) { // $sp[] = $thesp->textContent; $sp[] = $thesp->textContent; } 电流输出如下所示: SP为泡泡贝利(5/2)、焦奶油(4/1)、黑珍珠(5/1), 优质艺术(6/1)、温馨订单(8/1)、假想女主角(10/1

我正在提取一些文本并将其添加到数组中,如下所示:

    foreach($getthesp2 as $thesp)
            {
        //  $sp[] = $thesp->textContent;
            $sp[] =      $thesp->textContent;

        }
电流输出如下所示:

SP为泡泡贝利(5/2)、焦奶油(4/1)、黑珍珠(5/1), 优质艺术(6/1)、温馨订单(8/1)、假想女主角(10/1)、尼尔森 骄傲(12/1),趋势(12/1),洛博夫人(25/1)?SP是Mossgo (7/2),阿兰约(4/1),黄道日出(5/1),第一次叛乱(6/1), 无与伦比(7/1),查理(8/1),生活危险(12/1), 斯图德法默(12/1)、珀福德格林(16/1)

我需要它做的是将字符串拆分,然后将其添加到数组中,以便输出为:

SP为气泡贝利(5/2)SP为焦奶油(4/1)SP为黑珍珠(5/1)

使用
array_map()


我这样做是为了解决我的问题。

explode()有什么问题?
?尝试使用$sp=explode(',',$thesp->textContent);希望这对你有帮助我试过上面的,输出的是SP is阵列吗?SP是阵列吗?SP是阵列吗?那有什么用呢?请添加更多描述…
$sp = array("The SP is Bubbly Bailey (5/2)", "Burnt Cream (4/1)", "Pearl Noir (5/1)", "Quality Art (6/1)", "Warm Order (8/1)", "Imaginary Diva (10/1)", "Nelson's Pride (12/1)", "Trending (12/1)", "Senora Lobo (25/1)", "? The SP is Mossgo (7/2)"," Aaranyow (4/1)", "Ecliptic Sunrise (5/1)"," First Rebellion (6/1)", "Incomparable (7/1)", "Go Charlie (8/1)", "Live Dangerously (12/1)"," Studfarmer (12/1)", "Purford Green (16/1)");

function add_string($sp)
{
    // clean string
    $sp = str_replace("? The SP is ", '', $sp);
    $sp = str_replace("The SP is ", '', $sp);
    // concatenation
        return("The SP is ".$sp);
}
$sp_new = array_map("add_string", $sp);
print_r($sp_new);
    $tags = explode(',',$new);

foreach($tags as $key) {    
    if ($key !== "")
        {$sp[] = $key;}

}