title: How to Encode Web Image URL into JSON using PHP code
body: <p>I am writing an app in which i am allowing user to enter their product details into a framework [i have made on PHP] and then by using that framework i am encoding data into json and that encoded data i am retrieving in my Android App using web services.</p>
  
  <p>But now issue is i am not able to encode web image url therefore i am not getting correct image path in json:-</p>
  
  <p>Like: </p>
  
  <p>I have given this link to encode into JSON:</p>
  
  <pre><code>  "imageurl" =&gt; "http://www.libpng.org/pub/png/img_png/pnglogo-blk-sml1.png"
  </code></pre>
  
  <p>but whenever i see encoded web image url in JSON getting something like this:</p>
  
  <pre><code>    "imagepath":"http:\/\/www.libpng.org\/pub\/png\/img_png\/pnglogo-blk-sml1.png"
  </code></pre>
  
  <p><strong>why i am getting wrong image url....</strong></p>
  
  <p>I don't know how can i resolve this issue..please someone help me....</p>
  
  <p>albums.php:</p>
  
  <pre><code>      &lt;?php
  /*
  *Simple JSON generation from static array
  *Author: JSR
  */
  
  include_once './data.php';
  $albums = array();
  
  // looping through each album
  foreach ($album_tracks as $album) {
  $tmp = array();
  $tmp["id"] = $album["id"];
  $tmp["name"] = $album["album"];
  $tmp["description"] = $album["detail"];
  $tmp["imagepath"] = $album["imageurl"];
  $tmp["songs_count"] = count($album["songs"]);
  
  // push album
  array_push($albums, $tmp);
  }
  
  //printing json
  echo json_encode($albums);
  ?&gt;
  </code></pre>
  
  <p>data.php:</p>
  
  <pre><code>        &lt;?php
  /*
  *Simple JSON generation from static array
  *Author: JSR
  */
  $album_tracks = array(
  1 =&gt; array(
  "id" =&gt; 1,
  "album" =&gt; "Appetizers",
  "detail" =&gt; "All appetizers served with mint and tamarind chutneys.",
  "imageurl" =&gt; "http://www.libpng.org/pub/png/img_png/pnglogo-blk-sml1.png"
  )
  ));
  ?&gt;
  </code></pre>