jmurch Posted March 16, 2007 Share Posted March 16, 2007 I have a string 'firstword - secondword' that I want to split into two variables so that $var1 = firstword and $var2 = secondword. The '-' will always be the delimeter. Thanks Link to comment https://forums.phpfreaks.com/topic/43041-solved-string-help/ Share on other sites More sharing options...
per1os Posted March 16, 2007 Share Posted March 16, 2007 $string = "firstword - secondword"; $words = split(" - ", $string); foreach ($words as $word) { print $word . "<br />"; } Link to comment https://forums.phpfreaks.com/topic/43041-solved-string-help/#findComment-209051 Share on other sites More sharing options...
shaunrigby Posted March 16, 2007 Share Posted March 16, 2007 <?php $exploded = explode(" - ",$string); ?> The values will be stored in an array Link to comment https://forums.phpfreaks.com/topic/43041-solved-string-help/#findComment-209052 Share on other sites More sharing options...
jmurch Posted March 16, 2007 Author Share Posted March 16, 2007 Thanks guys................. Link to comment https://forums.phpfreaks.com/topic/43041-solved-string-help/#findComment-209054 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.