Home > Backend Development > PHP Tutorial > PHP实现简单搜歌的方法_PHP

PHP实现简单搜歌的方法_PHP

WBOY
Release: 2016-05-30 08:46:12
Original
868 people have browsed it

本文实例讲述了PHP实现简单搜歌的方法。分享给大家供大家参考。具体实现方法如下:

<form name="" method="post" action="">
<input name="key" type="text" /> <input name="submit" type="submit" value="搜歌" />
</form>
<pre class="brush:php;toolbar:false">
<&#63;php 
header('meta http-equiv="content-type"content="text/html; charset=gb2312"');
if( isset( $_REQUEST['submit']) && isset( $_REQUEST['key']))
$key = $_REQUEST['key'];
else $key = '周杰伦';
$url = 'http://music.sina.com.cn/yueku/search/getRecommendXml1dot0.php&#63;q='.urlencode($key).'&l=50&json=json';
$data = file_get_contents( $url);
$data = json_decode( $data);
if( !count($data)) echo 'Not found';
&#63;>
Copy after login
<?php foreach( $data as $one){ $music = $one->MP3URL; $music = file_get_contents( $music); $music = str_replace('iask_music_song_url="' , '', str_replace('";' , '', $music)); ?>
<?php echo 'ALBUM_NAME : '.$one->NAME.' MUSIC_URL : '.$one->NAME.''.' SINGER_NAME'.$one->SINGERCNAME;?>
<?php } ?>

希望本文所述对大家的php程序设计有所帮助。

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template