RE: Substr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



What about using explode()?

$array = explode('_', 'pid_1_date_2004_10_25');
$pid = $array[1];
$yr = $array[3];
$mn = $array[4];
$dy = $array[5];

Graham

> -----Original Message-----
> From: Shaun [mailto:shaunthornburgh@xxxxxxxxxxx]
> Sent: 25 October 2004 14:00
> To: php-general@xxxxxxxxxxxxx
> Subject:  Substr
> 
> 
> Hi,
> 
> I have a string as follows: pid_1_date_2004_10_25
> 
> pid tells me the Project_ID and date tells me the date(!). I need 
> to extract 
> this information from the string so to get the date I need 
> everything after 
> 'date_' as follows:
> 
> substr(strstr($key, 'date_'), 4)
> 
> However, to get the Project ID I need to extract everything after 
> 'pid_' and 
> everything before 'date_'. Can someone help me with this please as PHP 
> doesn't seem to provide a function for extracting information 
> from a string 
> that occurs before the 'needle'? 
> 
> -- 
> 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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux