我有這個變量$numbers
當我贊同這個$number
我很自然地看到這樣它包含這樣way->1,2,3,4,5
如何在值添加雙引號一個PHP變量中,並將其轉換爲一個數組
所以值 - >1,2,3,4,5
現在,請你告訴我如何變「$number
」轉換就像下面
$topic=array("1","2","3","4","5");
我有這個變量$numbers
當我贊同這個$number
我很自然地看到這樣它包含這樣way->1,2,3,4,5
如何在值添加雙引號一個PHP變量中,並將其轉換爲一個數組
所以值 - >1,2,3,4,5
現在,請你告訴我如何變「$number
」轉換就像下面
$topic=array("1","2","3","4","5");
你可以只使用explode
這在分隔符上分割一個字符串並返回一個數組。你不需要在數字周圍添加引號。
$topic = explode(',', $numbers);
很多錯別字這麼難理解,但我想你說的是數組在製作數組時正確的字符串數據類型? (?但typo'd死亡右)一切你已經提到
$number = array(1,2,3,4,5); //"1","2", are string litterals
foreach ($numbers as $number){
echo "<p>". $number . "</p>";
}
謝謝塞斯卡內基它完美的工作。 :) – 2012-01-09 15:47:23