Parse json data error in javascript

Whenever parse the encoded json data through jquery function $.parseJSON(data) ,It checks for json object format so parse json data error occur for the json array formated data pass in the function. To solve this issue data encode with the json_encode($data,JSON_FORCE_OBJECT).Read more …

How to replace the src attribute of the img tag from given html in php.

Here is the code for replace the ‘src’ attribute of the img tag from given html and return well formed html with new src content. $doc = new DOMDocument(); @$doc->loadHTML($html); $tags = $doc->getElementsByTagName(‘img’); foreach ($tags as $tag) { $old_src = $tag->getAttribute(‘src’); $new_src_url = WEBURL.$old_src; $tag->setAttribute(‘src’, $new_src_url); } $new_content = $doc->saveHTML();Read more …