Re: php equivalent for cut

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

 



The closest you get to 'cut' in PHP is probably the 'explode' command.  It splits a string by a delimiter like 'cut' does, only it dumps the results into an array:

$etcpasswd = "username:passwd:123:345::/home/username:/bin/sh";

$pwdarr = explode(":", $etcpasswd);

echo $pwdarr[4];

That should give you the 5th 'column' of the $etcpasswd string.

OR.. you could do this:

list($username, $passwd, $userid, $groupid, $something, $homedir, $defshell) = explode(":", $etcpasswd);

That'll take the array returned from explode() and put it into the variables used in $list.  It's been ages since I've messed with *nix /etc/passwd files, so forgive any inaccuracies in the field names I've used above.  You get the idea though.

Good luck Michelle!

-TG

= = = Original message = = =

Hello, 

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

Since the website <http://www.php.net/manual/de/> has no
seperated manuals for php4 and php5, it is not easy to
find the right stuff.

Greetings and good evening
Michelle


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

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