Jump to content

Explode.


eXeCuTeR

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.