12-07-2010, 07:38 AM
I need to search for "*" in $value. The below code is not matching. Please help.
echo "* is selected<br>";
12-07-2010, 07:43 AM
See http://www.php.net/preg_quote for a list of characters that must be escaped, or "quoted", to be literally matched.
preg_match( '/(\*)/', $value )
If all you're doing is checking for asterisks, or an asterisk count, it'll be much more efficient to use strpos() or substr_count():
if ( FALSE !== strpos( $value, '*' ) )
echo 'found at least one asterisk';
$asterisk_count = substr_count( $value, '*' );
if ( $asterisk_count > 0 )
echo 'number of asterisks found: ' . $asterisk_count;
12-07-2010, 09:32 AM
Thanks buddy... it solved the issue.