php - Why is strcasecmp not working? -
i doing string comparing in php, strcasecmp
outputs strings not equal.
here code:
<?php function multiexplode($delimiters,$string) { $ready = str_replace($delimiters, $delimiters[0], $string); $launch = explode($delimiters[0], $ready); homecoming $launch; } $owner = "musica no taatro: venha ja"; $owner_keys = multiexplode(array(".",":"," "),$owner); $musica_c = array("musica","teatro"); $musica = 0; if(sizeof($owner_keys) > 1){ foreach($musica_c $key_c){ foreach($owner_keys $cat){ if(strcasecmp($cat,$key_c)==0){ ++$musica; }else{ echo "do not match<br>"; } } } } ?>
why strcasecmp
observe different strings?
strcasecmp
doing work properly.
it matching 1 pair of string musica
& musica
. echo $musica;
in end. however, string pair different taatro
& teatro
. why not matching.
it expected behavior.
php strcmp
No comments:
Post a Comment