Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Oct 2005
    Posts
    61
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Lightbulb list mp3's only from a directory php

    looking for help to list mp3's only from a directory with php

    forexample:

    someonesong.mp3
    title: somonesong

    thank you in advance

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Use a glob.
    PHP Code:
    $sPath '/path/to/dir/*.mp3';
    foreach (
    glob($sPath) AS $mp3)
    {
        print 
    $mp3 PHP_EOL;

    Edit:
    Oh, and if you just want parts, use the pathinfo function in PHP to pull apart the path.

  • The Following 2 Users Say Thank You to Fou-Lu For This Useful Post:

    Adee (11-13-2011), pagedrop (11-13-2011)

  • #3
    New Coder
    Join Date
    Oct 2005
    Posts
    61
    Thanks
    12
    Thanked 0 Times in 0 Posts
    thank you for the reply.

    it shows the mp3 well.

    how can i integrate into format like this?

    <li><a href="#" data-src=dir/somesong.mp3">song name only</a></li>

    thank you

  • #4
    Regular Coder
    Join Date
    Jul 2010
    Location
    Oregon City
    Posts
    280
    Thanks
    5
    Thanked 50 Times in 49 Posts
    Quote Originally Posted by pagedrop View Post
    thank you for the reply.

    it shows the mp3 well.

    how can i integrate into format like this?

    <li><a href="#" data-src=dir/somesong.mp3">song name only</a></li>

    thank you
    PHP Code:
    $dir '/path/to/dir/*.mp3';

    foreach(
    glob($dir) as $mp3)
    {
        
    $k pathinfo($mp3);
        
    $m $k['basename'];
        
    $v explode(".",$k['basename']);
        echo 
    "<li><a href='#' data-src='dir/".$m."'>".$v[0]."</a></li>";




  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •