我想創建一個程序來確定一個字符串是否是迴文。檢測迴文中的php
這是我得到的錯誤。
聲明:Array對C字符串轉換:\ WAMP \ WWW \ task18.php上線22
我的代碼如下:
<?php
//TASK 18 PALINDROME
//use string split function to split a string into an array
$str = "Mum";
$str =strtolower($str);
$strArray = array();
$strArray = str_split($str);
$len = sizeof($strArray);
$reverseStr ="";
for($i=$len-1; $i>=0; $i--){
$reverseStr .=$strArray[$i];
}
if ($strArray == $reverseStr) {
echo " $strArray is a palindrome";
} else {
echo " $strArray is not a palindrome";
}
什麼線是22? – Albzi
echo「$ strArray不是迴文」; – Phill
你不能回顯數組。 – Med