This article illustrates a simple way to search for songs in PHP. Share to everyone for your reference. The implementation method is as follows:
<form name= "method=" POST "action=" "> <input name=" key "type=" text "/>" <input name= "Submit" type= "submit "Value="/> </form> <pre> <?php header (' Meta http-equiv= "Content-type" content= "text/html;
charset=gb2312 "');
if (Isset ($_request[' submit ')) && isset ($_request[' key ')) $key = $_request[' key '];
else $key = ' Jay Chou '; $url = ' http://music.sina.com.cn/yueku/search/getRecommendXml1dot0.php?q= '. UrlEncode ($key). '
&l=50&json=json ';
$data = file_get_contents ($url);
$data = Json_decode ($data);
if (!count ($data)) echo ' not found ';?> </pre> <?php foreach ($data as $one) {$music = $one->mp3url;
$music = file_get_contents ($music); $music = Str_replace (' iask_music_song_url= ', ', ', str_replace ('; ', ', $music));?> <div><?php Echo ' album_ NAME: '. $one->name. ' Music_url: <a href= '. $music. ' > '. $one->name. ' </a> '. ' Singer_name '. $one->singercname;?
></div> <?php}?>
I hope this article will help you with your PHP programming.