I am having a problem. I have a string in a variable. I split the string in to an array using explode function. But strlen function shows different lengths when I echo the string as an array element and echo the same string in strlen function. Below is my code
echo $schedule = 'Early Evening 6pm-9pm Tuesday, Early Evening 6pm-9pm Wednesday';
$scr = explode(",",$schedule);
$sc = array_map('trim', $scr);
print_r($sc);
echo strlen($sc[0]);
echo $sc[0];
echo '<br />';
echo 'string "Early Evening 6pm-9pm Tuesday" has '.strlen('Early Evening 6pm-9pm Tuesday'). ' chars<br />';
if(in_array('Early Evening 6pm-9pm Tuesday', $sc)){ echo 'yes'; } else { echo 'no'; }
and here is output:
Early Evening 6pm-9pm Tuesday, Early Evening 6pm-9pm Wednesday
Array ( [0] =>
Early Evening 6pm-9pm Tuesday [1] => Early Evening 6pm-9pm Wednesday
)
151 //length of first element of array
Early Evening 6pm-9pm Tuesday //first element of an array
string "Early Evening 6pm-9pm Tuesday" has 29 chars
no //I need yes here