php - Import Values of an Array into a Variable -


i'm new in php or programing @ , have problem can't solve alone. made test website can upload songs (filename = artist&song), , uploaded songs shown in table artist.

so created array music folder uploaded songs.

function displayfilename($artist, $song) { $songarray = array_slice(scandir('music/mp3'), 2); } 

the array looks this:

array ( [0] => hello&adele.mp3 [1] => hotline&drake.mp3 ) 

what need save first part of value in variable named $song , second part of value in value named $artist, , display them in table (i guess each). appreciate if try me problem^^

bye

loop $songarray, exploding values separator, &

echo '<table>'; foreach($songarray $sa) {     $exp = explode("&", $sa);     $song = $exp[0]; $artist = $exp[1];     echo '<tr>';     echo '    <td>' . $song . '</td>';     echo '    <td>' . $artist . '</td>';     echo '</tr>'; } echo '</table>'; 

Comments