Code Learner
Code Learner

Reputation: 13

php why str_replace not working with html

why here str_replace not working

<?php
$str= '<div class=\"droppable\" ondrop=\"drop(event)\" ondragover=\"allowDrop(event)\"></div>';
echo str_replace('\"','"', $str);

i want to use str_replace with HTML tag.

Upvotes: 0

Views: 154

Answers (1)

Sougata Bose
Sougata Bose

Reputation: 31749

As I get you want to remove the \s to get proper HTML.

Better way should be -

stripslashes('<div class=\"droppable\" ondrop=\"drop(event)\" ondragover=\"allowDrop(event)\"></div>');

Output

<div class="droppable" ondrop="drop(event)" ondragover="allowDrop(event)"></div>

stripslashes

Upvotes: 1

Related Questions