Re: [PHP] take text before '-' and after it

2002-12-12 Thread ed

 Wouldn't it be simpler to just remove the '-'?

$var = str_replace(-,,$var);

Ed


On Thu, 12 Dec 2002, Antti wrote:

 How can I take some text before the mark - and after it and put them for 
 example in array. The purpose of this is to read trough mp3 files which 
 are in the form of artist - song.mp3 and put them into a text file so I 
 can put them into mysql db.
 
 antti
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] take text before '-' and after it

2002-12-12 Thread Michael Montero
You can use split() or explode().

$string = 1234-5467 ;
list( $before_dash, $after_dash ) = explode( -, $string ) ;

or

$array = explode( -, $string ) ;

On Thu, 12 Dec 2002 [EMAIL PROTECTED] wrote:

 
  Wouldn't it be simpler to just remove the '-'?
 
 $var = str_replace(-,,$var);
 
 Ed
 
 
 On Thu, 12 Dec 2002, Antti wrote:
 
  How can I take some text before the mark - and after it and put them for 
  example in array. The purpose of this is to read trough mp3 files which 
  are in the form of artist - song.mp3 and put them into a text file so I 
  can put them into mysql db.
  
  antti
  
  
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 
 

-- 
Michael C. Montero
Chief Technology Officer
Community Connect Inc. Co-founder
[EMAIL PROTECTED]

-=-=-=-=-=  Community Connect Inc.  -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

The Premier Source of Interactive Online Communities149 Fifth Avenue
http://www.CommunityConnectInc.com/ New York, NY 10010

http://www.AsianAvenue.com/ http://www.BlackPlanet.com/
Click into Asian AmericaThe World Is Yours

http://www.MiGente.com/ http://www.DiversityJobMarket.com/
The Power of LatinosIn partnership with The New
York Times

-  Your Message May Appear Below This Line



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] take text before '-' and after it

2002-12-12 Thread 1LT John W. Holmes
 How can I take some text before the mark - and after it and put them for 
 example in array. The purpose of this is to read trough mp3 files which 
 are in the form of artist - song.mp3 and put them into a text file so I 
 can put them into mysql db.

$array = explode(-,$song);

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] take text before '-' and after it

2002-12-12 Thread Antti
[EMAIL PROTECTED] wrote:

 Wouldn't it be simpler to just remove the '-'?

$var = str_replace(-,,$var);

Ed


On Thu, 12 Dec 2002, Antti wrote:



How can I take some text before the mark - and after it and put them for 
example in array. The purpose of this is to read trough mp3 files which 
are in the form of artist - song.mp3 and put them into a text file so I 
can put them into mysql db.

antti


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





No, I don't want that 'couse the database has columns artist and song 
and I want to fill them with correct values. The thing is to read the 
files and put the values into an array. but I don't know how to do it...?

antti


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] take text before '-' and after it

2002-12-12 Thread Richard Baskett
$song = They Might Be Giants - No!.mp3

$arr = explode(' - ', $song);
$length = strlen($arr[1]); // gets char length of song

$artist = $arr[0];
$song = substr($arr[1], 0, ($length-4); // deletes the .mp3 off of song name

Cheers!

Rick

He who is devoid of the power to forgive is devoid of the power to love. -
Dr. Martin Luther King, Jr.

 From: Antti [EMAIL PROTECTED]
 Date: Thu, 12 Dec 2002 17:49:14 +0200
 To: [EMAIL PROTECTED]
 Subject: [PHP] take text before '-' and after it
 
 How can I take some text before the mark - and after it and put them for
 example in array. The purpose of this is to read trough mp3 files which
 are in the form of artist - song.mp3 and put them into a text file so I
 can put them into mysql db.
 
 antti
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] take text before '-' and after it

2002-12-12 Thread Antti


$array = explode(-,$song);

---John Holmes...


Ok, I got this. But still I don't know how to read the files from a 
directory and put them into an array so I can explode them.

antti


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] take text before '-' and after it

2002-12-12 Thread 1LT John W. Holmes
  $array = explode(-,$song);
  
  ---John Holmes...
 
 Ok, I got this. But still I don't know how to read the files from a 
 directory and put them into an array so I can explode them.

examples here:

http://www.php.net/manual/en/ref.dir.php

---John Holmes...

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] take text before '-' and after it

2002-12-12 Thread Justin French
Hi,

?
$file = Some Artist - Some Song.mp3;
list($artist,$song) = explode('-',$file);
$artist = trim($artist);
$song = trim(str_replace('.mp3','',$song));
?

Then you can do whatever you want with them... but I can't see why you'd
write them to a disk file AND write them to a mysql database -- wouldn't it
be one or the other?



on 13/12/02 2:49 AM, Antti ([EMAIL PROTECTED]) wrote:

 How can I take some text before the mark - and after it and put them for
 example in array. The purpose of this is to read trough mp3 files which
 are in the form of artist - song.mp3 and put them into a text file so I
 can put them into mysql db.
 
 antti
 

Justin French

http://Indent.com.au
Web Development  
Graphic Design



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php