Change the images URI values within an array In a custom module of services 3.x Drupal 7 that queries the database, I get the values of the URIs of some images within some nodes.

This is part of module:

$res = db_query("SELECT node.nid AS nid, node.title AS title, body.body_value AS body, fm.uri AS uri    
FROM {node} node 
INNER JOIN {field_data_body body} ON body.entity_id = node.nid 
INNER JOIN {field_data_field_header_image header} ON header.entity_id = node.nid 
INNER JOIN {file_managed fm} ON fm.fid = header.field_header_image_fid 
WHERE ((node.status = '1') AND (node.type IN ('tiendas')))
ORDER BY nid DESC");

foreach ($res as $cupon) {
$resultados[] = $cupon;
}
return resultados;


And this the json returned by the web services:

[
 {
  "nid": "6",
  "title": "Negron Beach Bar",
  "body": "&lt;p&gt;Este es el descuento de Negron&lt;/p&gt;\r\n",
  "uri": "public://negron.png"
 },
 {
  "nid": "5",
  "title": "PizaPuck",
  "body": "&lt;p&gt;Este es el descuento de PizaPuck&lt;/p&gt;\r\n",
  "uri": "public://pizapuck.png"
 }
]


But I need the full url. Not the URI. The json should look like this:

 {
  "nid": "5",
  "title": "PizaPuck",
  "body": "&lt;p&gt;Este es el descuento de PizaPuck&lt;/p&gt;\r\n",
  "uri": "http://example.com/site/default/files/pizapuck.png"
 }


If I use this from below I get the url I need (in $path), but I have to put the URI value by hand:

$uri = "public://pizapuck.png"; //by hand
if ($wrapper = file_stream_wrapper_get_instance_by_uri($uri)) {
$path = $wrapper-&gt;getExternalUrl();
}


How can I do to replace every URI value inside the array? I need to extract every value of URI, replace it with the path value, and put it back into the array? I understand this is basic and simple, but my knowledge of php, pdo, ppo and mysql are quite poor. Any help on this matter thank you in advance.
I think you will have success with 

file_create_url("public://pizapuck.png");


so

for ( $i = 0; $i &lt; count($resultados); $i++){
  $resultados[$i]['uri'] = file_create_url($resultados[$i]['uri']);
}


would loop through your results and change them. (untested code typed directly in here).