时间:2021-07-01 10:21:17 帮助过:20人阅读
$s = file_get_contents('http://simonfenci.sinaapp.com/index.php?key=simon&wd=1314abc');
preg_match_all('/\[word\] => (.+)/', $s, $m);
print_r($m[1]);
Array
(
[0] => 1314
[1] => abc
)
$s=file_get_contents('http://simonfenci.sinaapp.com/index.php?key=simon&wd=1314abc');
$rule='#(?<=\[word\] =>)\s\w+#';
preg_match_all($rule,$s,$arr);
print_r($arr);
Array
(
[0] => Array
(
[0] => 1314
[1] => abc
)
)
$arr = array(
0=>array(
'word '=> 1314,
'word_tag'=> 90,
'index' => 0
),
1 => Array(
'word' => 'abc',
'word_tag' => 95,
'index' => 1
)
);
echo( json_encode($arr) );
$arr = array();
$url = 'http://simonfenci.sinaapp.com/index.php?key=simon&wd=1314abc';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
$output = curl_exec($ch);
$arr = json_decode($output,true);
curl_close($ch);