str_replace on variable for $post->post_title
In the popup I’ve got the post title coming up. It works fine if I have an apostrophe in the title, but not if I have speechmarks / quotation marks
I’m currently using the following:
$variable = $post->post_title; $variable = str_replace(array("'",""), "\'", $variable);
Adding the following to cater for speechmarks does not work:
$variable = str_replace(array('"',''), '\\"', $variable);
Can anyone help me please?
- The topic ‘str_replace on variable for $post->post_title’ is closed to new replies.