未定義變量爲$new_string
。
我寫了這個小腳本,因爲我需要它,(不要問爲什麼)。
$string = "abcdefghijklmnopqrstuvwxyz"; // just used as an example
// $string becomes "badcfehgjilknmporqtsvuxwzy"
$now_in_pairs = str_split($string, 2);
$reverse = array_map('strrev', $now_in_pairs);
foreach($reverse as $r) {
$new_string .= $r;
}
echo $new_string;
我知道我可以簡單地說,$new_string = NULL
在一開始就避免了未定義的變量,但它不能幫助我理解爲什麼它沒有被定義。
非常外行的說法,$r
等於數組中每對的值?
$new_string
如何等於$r
?
的implode功能我明白了。謝謝。我認爲第一個循環將被認爲是等於,並且後面的循環是附加的。我的假設是錯誤的。 – Tom 2014-09-26 05:27:42
@湯姆。總是歡迎。很高興幫助你:) – Jenz 2014-09-26 05:28:38