I'm trying to remove a string of HTML from another string, but for some reason nothing happens and it doesn't get removed.
The code I'm using is:
$saveContent = str_replace('<input type="hidden" name="formID" value="'.$id.'" />','',$saveContent);
The string doesn't get replaced. I want to remove the hidden element before I enter it in a DB.
Am I missing something?
i believe this is what you are looking for:
$content_editor = strip_tags($content_editor);
$content_editor = html_entity_decode($content_editor);
Use PHP Simple HTML Dom Parser to remove the html piece you want and do more, it's similar to jquery (with selectors and stuff).
Or just use jquery (or any javascript) to do the element removal to the browser side.
Try replacing them with double quotes
$saveContent = str_replace("<input type='hidden' name='formID'
value='$id'/>","",$saveContent);
P.s:str_replace only works if you have the exact text to replace . I mean The whole input format should have even same number of space.