|
Posted by tg-php on 09/06/05 19:18
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.
Navigation:
[Reply to this message]
|