一個辦法做到這一點檢出PHP demo:
//your starting array
$myarray = array("lenny/volatile/main Packages","lenny/volatile/main Packages", "lenny/volatile/main Sources", " Reading package", "lenny/volatile/main Sources");
$mystring = implode(",", $myarray); //implode array into a string delimited by ,
echo $mystring.PHP_EOL.PHP_EOL; //debug
$mystring = str_replace(", ", ' ', $mystring); //str replace all ", " with ' '
echo $mystring.PHP_EOL.PHP_EOL; //debug
$result= explode(',',$mystring); //explode back into an array with delimiter ','
print_r($result); //should give you final result
輸出結果@邁克爾:
lenny/volatile/main Packages,lenny/volatile/main Packages,lenny/volatile/main Sources, Reading package,lenny/volatile/main Sources
lenny/volatile/main Packages,lenny/volatile/main Packages,lenny/volatile/main Sources Reading package,lenny/volatile/main Sources
Array
(
[0] => lenny/volatile/main Packages
[1] => lenny/volatile/main Packages
[2] => lenny/volatile/main Sources Reading package
[3] => lenny/volatile/main Sources
)
正是我一直在尋找。謝謝大家! – Darrow11 2011-03-11 21:12:02