我得到这样的卷曲响应,
<result>
<term>ve</term>
<rhymes>
mckie, mcnee, mcphee, mcphie, mcree, mcvea, moree, mt, musee, nabil, mckey, mcghie, mcghee, macphee, magee, marie, marquee, marquis, mc, mcbee, mccree, mcfee, mcgee, nestle, ot, partee, se
</rhymes>
</result>
我需要<rhymes>
从 curl 响应中获取一串数组的结果。
请帮我整理一下
我把完整的脚本放在这里,请有人检查......
$request = 'http://www.stands4.com/services/v2/rhymes.php';
// The request parameters
$uid = '2634';
$tokenid = 'kqjhvZfLrUQdrOCB';
echo $term = "a";
echo strlen($term);
// urlencode and concatenate the POST arguments
$postargs = 'uid='.$uid.'&tokenid='.$tokenid.'&term='.$term;
// build request format
$session = curl_init($request);
// Tell curl to use HTTP POST
curl_setopt ($session, CURLOPT_POST, true);
// Tell curl that this is the body of the POST
curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs);
// Tell curl not to return headers, but do return the response
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER,1);
$response = curl_exec($session);
$rhymes_xml = simplexml_load_string($response);
$rhymes = (string) $rhymes_xml->rhymes; //extract the string from the XML
$rhymes_array = explode(', ',$rhymes);
print_r($rhymes_array);