Warning: strpos(): Empty needle in

Havent come across this error before and have googled it, and dont really understand it.

Warning: strpos(): Empty needle in


if ($radioB == "hotel") {
$count = 0;
$choice = $in;
if (is_array($mainArray)){
foreach($mainArray as $hotel) {
  if (strpos(strtoupper(normalize($hotel['Nom_Hot'])), strtoupper(normalize($in))) !== false) $count++;
 $num_rows = $count;

I’ve not come across the error before but

strpos($haystack, $needle)

It seems to be saying the 2nd parameter is empty.

Ah hang on, is it because i have made $choice equal to $in, and then used $in perhaps

$choice does not seem to do anything, so no.
It seems the result of strtoupper(normalize($in)) is empty.
Could that be due to else{$in='';}?

OOO, that needs to stay like that too, and so ye it possibly is

I think stuffing everything all in one line can sometimes cause problems. Some functions may work wrapped around everything else while others may not. I mean it’s faster and saves you time and tons of lines of code, but simplicity can also lead to a “simple” mistake.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.