how to convert non breaking space to &nbsp; in php : <p>here is my string</p>

<pre><code>hello


world



hello world
</code></pre>

<p>how can I convert this string to </p>

<pre><code>hello

&amp;nbsp;

world

&amp;nbsp;

&amp;nbsp;

hello world
</code></pre>

<p>in php. Any one help please... </p>
