sager29 Posted August 19, 2010 Share Posted August 19, 2010 Is it possible to split a variable into 2 variables? /// I have this sentence $item = "Below Telegraph Hill, Smallwork Canvas Edition"; /// And I want to be able to do this $item = "Below Telegraph Hill" ; $medium = "Smallwork Canvas Edition"; Is it possible to find the comma in a string, and remove the comma & everything before or after it? Any recommendations would be appreciated. Link to comment https://forums.phpfreaks.com/topic/211224-split-a-variable-into-2-variables/ Share on other sites More sharing options...
teng84 Posted August 19, 2010 Share Posted August 19, 2010 /// I have this sentence $item = "Below Telegraph Hill, Smallwork Canvas Edition"; list($var1,$var2)= explode(',',$item); echo $var1; echo $var2; Link to comment https://forums.phpfreaks.com/topic/211224-split-a-variable-into-2-variables/#findComment-1101414 Share on other sites More sharing options...
sager29 Posted August 19, 2010 Author Share Posted August 19, 2010 Works perfectly. Thanks, just saved me hours of time. Link to comment https://forums.phpfreaks.com/topic/211224-split-a-variable-into-2-variables/#findComment-1101417 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.