How to replace a string in PHP?
<p><strong>I have a variable which contains a string like the one written below:</strong></p>

<pre><code>&lt;p&gt;The post &lt;a href="http://zed1.com/journalized/archives/2012/03/11/wordpress-3-for-business-bloggers/"&gt;WordPress 3 for Business Bloggers&lt;/a&gt; appeared first on &lt;a href="http://zed1.com/journalized"&gt;Mike Little&amp;#039;s Journalized&lt;/a&gt;.&lt;/p&gt;";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:7:"pubDate";a:1:{i:0;a:5:{s:4:"data";s:31:"Sun, 10 Feb 2013 17:00:13 +0000";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}s:32:"http://purl.org/dc/elements/1.1/";a:1:{s:7:"creator";a:1:{i:0;a:5:{s:4:"data";s:11:"Mike Little";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}}}i:49;a:6:{s:4:"data";s:13:"






";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";s:5:"child";a:2:{s:0:"";a:5:{s:5:"title";a:1:{i:0;a:5:{s:4:"data";s:85:"WordPress.tv: Cliff Seal: Content Strategy – No one cares about your content (yet.)";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:4:"guid";a:1:{i:0;a:5:{s:4:"data";s:28:"http://wordpress.tv/?p=15209";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:4:"link";a:1:{i:0;a:5:{s:4:"data";s:95:"http://wordpress.tv/2013/02/09/cliff-seal-content-strategy-no-one-cares-about-your-content-yet/";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:11:"description";a:1:{i:0;a:5:{s:4:"data";s:710:"&lt;div id="v-7wXyrfye-1" class="video-player"&gt;
&lt;/div&gt;
&lt;br /&gt;  &lt;a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wptv.wordpress.com/15209/"&gt;&lt;img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wptv.wordpress.com/15209/" /&gt;&lt;/a&gt; &lt;img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wordpress.tv&amp;blog=5089392&amp;post=15209&amp;subd=wptv&amp;ref=&amp;feed=1" width="1" height="1" /&gt;&lt;div&gt;&lt;a href="http://wordpress.tv/2013/02/09/cliff-seal-content-strategy-no-one-cares-about-your-content-yet/"&gt;&lt;img alt="Cliff Seal: Content Strategy – No one cares about your content yet" src="http://videos.videopress.com/7wXyrfye/video-93ee0cad15_std.original.jpg" width="160" height="120" /&gt;&lt;/a&gt;&lt;/div&gt;";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}s:7:"pubDate";a:1:{i:0;a:5:{s:4:"data";s:31:"Sat, 09 Feb 2013 18:29:33 +0000";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}s:32:"http://purl.org/dc/elements/1.1/";a:1:{s:7:"creator";a:1:{i:0;a:5:{s:4:"data";s:12:"WordPress.tv";s:7:"attribs";a:0:{}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";}}}}}}}}}}}}}}}}s:4:"type";i:128;s:7:"headers";a:9:{s:6:"server";s:5:"nginx";s:4:"date";s:29:"Thu, 21 Feb 2013 05:50:08 GMT";s:12:"content-type";s:8:"text/xml";s:14:"content-length";s:5:"72893";s:10:"connection";s:5:"close";s:4:"vary";s:15:"Accept-Encoding";s:13:"last-modified";s:29:"Thu, 21 Feb 2013 05:30:17 GMT";s:4:"x-nc";s:11:"HIT luv 139";s:13:"accept-ranges";s:5:"bytes";}s:5:"build";s:14:"20121202164312";}','no'),(380,'_transient_timeout_feed_mod_867bd5c64f85878d03a060509cd2f92c','1361468731','no'),(381,'_transient_feed_mod_867bd5c64f85878d03a060509cd2f92c','1361425531','no'),(382,'_transient_timeout_dash_aa95765b5cc111c56d5993d476b1c2f0','1361468731','no'),(383,'_transient_dash_aa95765b5cc111c56d5993d476b1c2f0','&lt;div class="rss-widget"&gt;&lt;ul&gt;&lt;li&gt;&lt;a class='rsswidget' href='http://ma.tt/2013/02/new-yahoo-2/' title='Marissa Mayer announces the new Yahoo hompage, on a WordPress-powered blog. [&amp;hellip;]'&gt;Matt: New Yahoo&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class='rsswidget' href='http://ma.tt/2013/02/100-gpl/' title='Creative Market just announced that all of their WordPress Themes are now 100% GPL, meaning to list in their marketplace and reach their users your theme must provide users with the same freedoms that WordPress itself does. They have some great themes already. This is fantastic news and I’m very proud of their team for taking this bold step, and as promised  [&amp;hellip;]'&gt;Matt: 100% GPL&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class='rsswidget' href='http://wordpress.tv/2013/02/20/leslie-hancock-developing-a-distinctive-online-voice/' title=' [&amp;hellip;]'&gt;WordPress.tv: Leslie Hancock: Developing a Distinctive Online Voice&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class='rsswidget' href='http://wordpress.tv/2013/02/20/scott-basgaard-help-yourself-by-helping-others/' title=' [&amp;hellip;]'&gt;WordPress.tv: Scott Basgaard: Help Yourself by Helping Others&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a class='rsswidget' href='http://feedproxy.google.com/~r/weblogtoolscollection/UXMP/~3/3tj7MIPbhOc/' title='The new default theme for WordPress 3.6, titled Twenty Thirteen, is making progress. This year’s default theme is overseen by Matt Mullenweg, and built by Joen Asmussen, Konstantin Obenland, and Lance Willett. The goal for Twenty Thirteen is to offer “a focus on blogging, and great support for post formats (which are getting attention on the backend in 3.6 a [&amp;hellip;]'&gt;Weblog Tools Collection: Twenty Thirteen Theme in Progress&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;','no'),(384,'_transient_timeout_feed_57bc725ad6568758915363af670fd8bc','1361468732','no'),(385,'_transient_feed_57bc725ad6568758915363af670fd8bc','a:4:{s:5:"child";a:1:{s:0:"";a:1:{s:3:"rss";a:1:{i:0;a:6:{s:4:"data";s:3:"

";s:7:"attribs";a:1:{s:0:"";a:1:{s:7:"version";s:3:"2.0";}}s:8:"xml_base";s:0:"";s:17:"xml_base_explicit";b:0;s:8:"xml_lang";s:0:"";s:5:"child";a:1:{s:0:"";a:1:{s:7:"channel";a:1:{i:0;a:6:{s:4:"data";s:72:"
</code></pre>

<p>Now I want to replace some words from it. So I used the code written below:</p>

<pre><code>    if(strstr($sql, "href='")){
        str_replace("href='", 'href="', $sql);
$data = $sql;
fwrite($handle, $data);
    }
</code></pre>

<p>But I did not get any result. So please help if there is some wrong I have done.</p>
