Rottingham Posted April 27, 2010 Share Posted April 27, 2010 Ok So I want the pro way to do this. I have a string that I just want to pick the first six characters out. My string looks like CEE500 - Open I just want the CEE500. Now I know this is like 'duh'... But, I've tried split ('-', $string) and it returns the whole string, I've tried preg_split('/ /', $string) and I get the whole string. I could do $string=$string[0].$string[1]...$string[5] but that' a lousy way... Any suggestion? Quote Link to comment Share on other sites More sharing options...
teamatomic Posted April 27, 2010 Share Posted April 27, 2010 $str='CEE500 - Open'; $string=substr("$str", 0, 6); HTH Teamatomic Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted April 27, 2010 Share Posted April 27, 2010 Is there a reason in wrapping $str in quotes? Quote Link to comment Share on other sites More sharing options...
teamatomic Posted April 27, 2010 Share Posted April 27, 2010 Habit. As examples, I prefer: "this is a $var to echo out" over 'this is a'.$var.'to echo out' and file("$file") over file($file) HTH Teamatomic Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.