Okay so I use PHP to replace titles, keywords and descriptions on my website: $title = "Watch " . $var . " Full Movie Online Free"; $keywords = "Watch " . $var . " Free, Watch " . $var . " movies, watch " . $var . " movies, free online movies, watch free movies, "; $description = "Watch " . $var . " Free"; PHP: That's the code to replace the keywords in my header, which I PHP include. The problem is that sometimes users search e.g. Watch Up Free This will then put Watch Watch Up Free Free because I'm already declaring "Watch" and "Free" So I tried writing a bit of code: if { (!strpos($description, "watch")) } then { $description = "" . $title . ""; } else { ($description = ("Watch " . $title . " Free" ) } PHP: But I'm just getting errors. Is it possible to check if "Watch" and "Free" exist within the string and use an ELSE statement add jut " . $title . " instead of Watch " . $title . " Free Or am I just wasting my time? The only reason I want to sort this is because Google are indexing these pages.
i don't understand the full post but yes you can check if certain keyword exists and use else statement. $keycheck = (bool) strstr("$description", "watch"); it will return 1 when it finds watch in $description. if($keycheck ==1){ statement for true }else { }
Thanks for your reply. I've since edited my sloppy code and come up with: if (!strpos($description, "watch " . $var . " free")) { $description = "" . $var . ""; } else { $description = "Watch " . $var . " Free"; } PHP: It just needs organizing but I'm not the biggest PHP person so I'm completely clueless from here on, anyway you can edit this for me? $var is the searched item.
Try this one: //Just add the words you want to removed from $var $remove = array("Watch", "up", "Free"); //This should convert all the words you added from $remove to empty string $newvar = str_replace($remove, "", $var); //You can now use your previous code but use $newvar instead $title = "Watch " . $newvar . " Full Movie Online Free"; $keywords = "Watch " . $newvar . " Free, Watch " . $newvar . " movies, watch " . $newvar . " movies, free online movies, watch free movies, "; $description = "Watch " . $newvar . " Free"; I hope it helps.. Goodluck..