Asked By
groat n
0 points
N/A
Posted on - 02/23/2013
I'm trying to make a basic text search engine using MySQL/PHP with the script <? PHP $text ="Hello World!"; if ($text contains "world") {echo "True";}? >.
Why is it that I'm having an error of "Fatal error: Call to undefined function empty () in /home/h's/public_html/sign/searchtest.php on line 60"?
I need PHP simple free text search script.
Thanks.
In need of Php simple free text search script
Hi Groat,
This can be easily done using PHP string functions like following:
strpos: Find the position of the first occurrence of a substring in a string
strstr:Find the first occurrence of a string
strpbrk: Search a string for any of a set of characters
strcmp : Binary safe string comparison
<?php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
if ($pos === false) {
echo "The string '$findme' was not found in the string '$mystring'";
} else {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}
?>
Thanks.