eXeCuTeR Posted March 7, 2008 Share Posted March 7, 2008 Assuming I have a variable that contains website:username (note the ':') Now, I wanna explode this variable into 2 variables, one to hold the website part and one to hold the username part. Hmm, e.g: $result = "website:username"; Store the website part of the string in one variable ($hello for example) and username in $bye. I've tried many ways, non of them worked perfectly. Thanks. Link to comment https://forums.phpfreaks.com/topic/94989-explode/ Share on other sites More sharing options...
BlueSkyIS Posted March 7, 2008 Share Posted March 7, 2008 maybe list($hello,$bye) = explode(':',$result); Link to comment https://forums.phpfreaks.com/topic/94989-explode/#findComment-486579 Share on other sites More sharing options...
eXeCuTeR Posted March 8, 2008 Author Share Posted March 8, 2008 NVM. Link to comment https://forums.phpfreaks.com/topic/94989-explode/#findComment-486592 Share on other sites More sharing options...
BlueSkyIS Posted March 8, 2008 Share Posted March 8, 2008 works for me: <? $result = "website:username"; list($hello,$bye) = explode(':',$result); echo "hello: $hello<BR>bye: $bye<BR>"; ?> output: hello: website bye: username Link to comment https://forums.phpfreaks.com/topic/94989-explode/#findComment-486593 Share on other sites More sharing options...
deadonarrival Posted March 8, 2008 Share Posted March 8, 2008 Do you get an error message? Are you sure $result does contain the correct things? stick <?php print "<hr />Result = $result<br />"; print "Website = $website<br /">". print "User = $user<hr />"; ?> in your script just after either <?php list($website,$user) = explode(':',$result); ?> or if that really doesn't work with no errors. <?php $vars = explode(':',$result); $website = $result[0]; $user = $result[1]; ?> Link to comment https://forums.phpfreaks.com/topic/94989-explode/#findComment-486595 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.