```
~~~
/**
* @param array $data
* @return array
* 自动获取查询的图片,补全url
* 一维数组
*/
function get_host_img($data=array()){
foreach ($data as $k=>$v)
{
$file_txt = substr($v,-3);
if ($file_txt == 'jpg'|| $file_txt == 'png' || $file_txt == 'gif')
{
if(!preg_match("/^http(s)?:\\/\\/.+/",$v))
{
$host = C('HOST_URL');
//截取第一个‘/’后面的内容
// $substr_data = substr($v,strpos($v,'.')+1);
$substr_data = trim($v,'.');
$data[$k] = $host.$substr_data;
}else{
$data[$k] = $v;
}
}
}
return $data;
}
~~~
```