Categories :

How To Search In PHP Array Element Containing String | Like Binod

$example = array(
        “who” => “Who is Binod?”,
        “name” => “Dose Binod Tharu is Binod?”,
“where” => “Where is Binod?”,
“whose” => “Whose name is binod?”,
“YouTube” => “Dose Binod in the YouTube?”,
“meaning” => “What is Binod meaning?”,
“fullform” => “What is Binod full form?”,
“pronunciation” => “What is Binod pronunciation?”,
“english” => “Dose Vinod in english”,
“how” => “How to write Vinod in sanskrit?”,
“nickname” => “Which best nickname for Vinod?”,
“kon” => “Binod kon he?”,
“kaha” =>”Binod kaha he?”,
“kiska” =>”Binod kiska name he?”
$searchword = ‘Binod’;
$search_results = array_filter($example, function($var) use ($searchword) {
return preg_match(“/b$searchwordb/i”, $var); 
echo “Search Word: “.$searchword;
echo “<br>Search Results”;
echo “<pre>”;
echo “Total Search: “.count($search_results);
echo “<hr>”;
echo “</pre>”;

Leave a Reply

Your email address will not be published. Required fields are marked *