$searchstr
$searchstr = preg_replace('/[^A-Za-z0-9\-]/', '', $searchstr);fisearchstr
[[!+fi.searchstr]]
&successMessage=`[[!habitats_search? &searchstr=`[[!+fi.searchstr]]`]]`
preg_match("/$searchstr/i", $v)preg_match("/".$searchstr."/i", $v)preg_match('@'.$searchstr.'@i', $v)
... some code for the list for the autocomplete function ...
$js = "<script>
$(function() {
var availableTags = ['".implode('\',\'',$result)."'];
$( '#searchstr' ).autocomplete({
source: availableTags,
minLength: 3
});
});
</script>";
$modx->regClientStartupScript($js);
echo"[[!FormIt?
&store=`1`
&validate=`searchstr:required`
&successMessage=`[[!habitats_search? &searchstr=`[[!+fi.searchstr]]` &phy=`".$phy."`]]`
]]
[[!FormItRetriever]]
[[!+fi.validation_error_message:!empty=`
...
`]]
<form action='[[~[[*id]]]]' method='post'>
<div class='col-lg-12'>
<div class='input-group custom-search-form'>
<input type='text' class='form-control' name='searchstr' id='searchstr' value='[[!+fi.searchstr]]'>
<span class='input-group-btn'>
<button class='btn btn-default' type='submit'>
<span class='glyphicon glyphicon-search'></span>
</button>
</span>
</div><!-- /input-group -->
</div>
</form>
<br><br><br>
[[!+fi.successMessage]]
";
... some code for the array $result ...
echo "search for: $searchstr<br><br>\n";
echo "var_dump: ";
var_dump($searchstr);
echo "<br><br>\n";
if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $searchstr))
{
echo "special chars found!<br><br>\n";
}
$searchstr = preg_replace('/[^a-zA-Z0-9_ -]/s', '', $searchstr);
if (preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $searchstr))
{
echo "special chars found 2!<br><br>\n";
}
echo "strip done: ";
print($searchstr);
echo "<br><br>\n";
foreach ($result as $d)
{
foreach ($d as $v)
{
if(preg_match("/$searchstr/i", $v))
{
$f = 1;
}
}
if ($f == 1)
{
echo "found : ".$d[2]."<br>\n";
unset($f);
}
}
search for: Arabidion alpinae
var_dump: string(18) "Arabidion alpinae"
special chars found!
strip done: fisearchstr
found : --! test entry with fisearchstr !--
$output = ''; $output .= "search for: $searchstr<br><br>\n";
return $output;
&successMessage=`[[!habitats_search? &searchstr=`[[!+fi.searchstr]]` &phy=`".$phy."`]]`
&successMessage=`[[!habitats_search? &searchstr=`".$_POST['searchstr']."` &phy=`".$phy."`]]`