Re: Re: php equivalent for cut

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

 



I am searching for the right equivalent for "cut -d : -f5"
but it must work with php4.

$fields = explode(':', $string, 5);

Hmmm.. that's going to create a 5 element array assigned to $fields. So, using /etc/passwd as an example...

philip:*:1000:1000:Philip Hallstrom:/local/home/philip:/bin/tcsh

$fields is going to look like this:

0 = philip
1 = *
2 = 1000
3 = 1000
4 = Philip Hallstrom:/local/home/philip:/bin/tcsh

I think what he really wants is:

$fields = explode(':', $string);
$fullname = $fields[4]; // Philip Hallstrom


-philip

--
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