compare string like %LIKE% function in php
you can use the
stristr() function,
string stristr ( string $haystack , mixed $needle [, bool $before_needle ] )
if (stristr($namerow['honors'], 'hall of fame')) {
$asterisk = '*';
} else {
$asterisk = '';
}
or even more compact:
$asterisk = (stristr($namerow['honors'], 'hall of fame') ? '*' : '');
Note:
this is for case insensitive comparing. If you want it to only match hall of fame and not HaLL of FamE, use just strstr() (it's the same format)
No comments:
Post a Comment