I am writing this code, but instead of executing it in the browser, such a thing appears. The site redirected too many times, tell me how to fix it?
function redirect_subdomen( $current_city, $arr ) { foreach($arr as $k => $v){ if($k == $current_city){ header("Location: http://".$v[0]);break; } } } if($arAuto["CITY_NAME"] == $usrSelCity){ redirect_subdomen($arAuto["CITY_NAME"], $arrDate); } if($arAuto["CITY_NAME"] != $usrSelCity){ redirect_subdomen($usrSelCity, $arrDate); }
if, butif {} else {}. In general, look at your code:header("Location: http://".$v[0])- you always go to the address that is contained in the array element with index 0. The correct code will be like this:header("Location: http://".$v[$k]). If I am right, let me know, I will issue this comment as an answer to your question, then you can accept it. - Stanislav Belichenkoheader("Location: http://".$v[$k][0])- Stanislav Belichenko$arr[$k][0]or$v[0](as it was). and your$v[$k][0]is some kind of nonsense. - teran