Re: Re: php equivalent for cut

From: Date: Tue, 06 Sep 2005 18:22:11 +0000
Subject: Re: Re: php equivalent for cut
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-221920@lists.php.net to get a copy of this message
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

« previous php.general (#221920) next »