rendered paste body<?php
/**
* @author alihammad
* @copyright 2007
*/
$string1="my name is ali hammad and trying to make a search engine template".
" Islamabad is my city i never disliked it i love it";
echo "<h3> Search any string from the article below</h3><br /><br />";
echo "<p><pre>".$string1."</p></pre>";
?>
<form action="explode().php" method="POST">
<input type="text" name="str" />
<input type="submit" value="search" />
</form>
<pre>
<?php
if(isset($_POST['str']))
{
if((strpos($_POST['str'], " "))!=FALSE)
{
$counter=0;
$str=$_POST['str'];
$strings=explode(" ", $str);
$string2=explode(" ", $string1);
foreach($string2 as $values1)
{
foreach($strings as $values2)
{
if($values2==$values1)
{
$counter=1;
}
}
if($counter!=1)
{
echo "$values1 ";
}
else if($counter==1)
{
echo "<b>$values1</b> ";
$counter=0;
}
}
}
else if(strpos($_POST['str'], " ")==FALSE||strpos($_POST['str'], " ")<=0)
{
$str=$_POST['str'];
$strings=explode(" ", $str);
foreach($strings as $values)
{
if($values==$str)
{
echo "<b>$str</b> ";
}
else if($values!=$str)
{
echo "$values ";
}
}
}
}
?>
</pre>