public function huancheng($key) { $key="永兴村到山水人家"; $str=""; $keys=explode('到',$key); $json = @file_get_contents("http://api.map.baidu.com/direction/v1?mode=transit&origin=".$keys[0]."&destination=".$keys[1]."®ion=舟山&output=json&ak=gfPnxaaiPyNIhM7c3eZ1kmEL"); $ar = json_decode($json,true); array_walk_recursive($ar, 'funv'); function funv($v, $k) { global $str; if($k == 'stepInstruction') {$str.= strip_tags($v);} } return $str; }
public function huancheng($key) { global $str; $key="永兴村到山水人家"; $str=""; $keys=explode('到',$key); $json = @file_get_contents("http://api.map.baidu.com/direction/v1?mode=transit&origin=".$keys[0]."&destination=".$keys[1]."®ion=舟山&output=json&ak=gfPnxaaiPyNIhM7c3eZ1kmEL"); $ar = json_decode($json,true); array_walk_recursive($ar, 'funv'); return $str; } function funv($v, $k) { global $str; if($k == 'stepInstruction') {$str.= strip_tags($v);} }
别岐视php5.2.
第一次见有人这样写东西
public function huancheng($key)
{
function funv($v, $k)
{
}
return $str;
}
代码看不懂。不好意思。
public function huancheng($key) { global $str; $key="永兴村到山水人家"; $str=""; $keys=explode('到',$key); $json = @file_get_contents("http://api.map.baidu.com/direction/v1?mode=transit&origin=".$keys[0]."&destination=".$keys[1]."®ion=舟山&output=json&ak=gfPnxaaiPyNIhM7c3eZ1kmEL"); $ar = json_decode($json,true); array_walk_recursive($ar, 'funv'); return $str; } function funv($v, $k) { global $str; if($k == 'stepInstruction') {$str.= strip_tags($v);} }
如果 funv 是作为类的方法出现的,则应
array_walk_recursive($ar, array($this, 'funv'));
如果 funv 是作为类的方法出现的,则应
array_walk_recursive($ar, array($this, 'funv'));