nathanmaxsonadil Posted August 31, 2007 Share Posted August 31, 2007 is there something like explode but instead of like this $data = "foo:*:1023:1000::/home/foo:/bin/sh"; list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data); echo $user; // foo echo $pass; // * it would go like this $data = "foo:*:1023:1000::/home/foo:/bin/sh"; list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data); echo $user; // foo: echo $pass; // *: Link to comment https://forums.phpfreaks.com/topic/67486-solved-like-explode-ex/ Share on other sites More sharing options...
phpSensei Posted August 31, 2007 Share Posted August 31, 2007 I don't really understand... you want "Foo:" instead of "Foo"? Link to comment https://forums.phpfreaks.com/topic/67486-solved-like-explode-ex/#findComment-338787 Share on other sites More sharing options...
roopurt18 Posted August 31, 2007 Share Posted August 31, 2007 You lose the colon when you perform the explode, so just manually concatenate it back on: $data = "foo:*:1023:1000::/home/foo:/bin/sh"; list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data); echo $user . ":"; // foo: echo $pass . ":"; // *: Link to comment https://forums.phpfreaks.com/topic/67486-solved-like-explode-ex/#findComment-338790 Share on other sites More sharing options...
phpSensei Posted August 31, 2007 Share Posted August 31, 2007 Edit: NVM, someone already posted. Link to comment https://forums.phpfreaks.com/topic/67486-solved-like-explode-ex/#findComment-338795 Share on other sites More sharing options...
nathanmaxsonadil Posted August 31, 2007 Author Share Posted August 31, 2007 k thanks Link to comment https://forums.phpfreaks.com/topic/67486-solved-like-explode-ex/#findComment-338803 Share on other sites More sharing options...
Psycho Posted August 31, 2007 Share Posted August 31, 2007 Or simply add a different character to do the explode on. <?php $data = "foo:*:1023:1000::/home/foo:/bin/sh"; $data = str_replace(':', ':|', $data); list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode("|", $data); echo $user; // foo: echo $pass; // *: ?> Link to comment https://forums.phpfreaks.com/topic/67486-solved-like-explode-ex/#findComment-338811 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.