rondog Posted November 26, 2010 Share Posted November 26, 2010 I tried to do this: explode(" ",$cp['size'])[0] and it isn't working obviously. The reason I want it in one line is its in the middle of a big string and I'd like to keep all the code in one area. Is their a right way to do that other than setting it to a variable first? Quote Link to comment Share on other sites More sharing options...
rondog Posted November 26, 2010 Author Share Posted November 26, 2010 I found this to work stristr($cp['size']," ",true) Except its php 5.3.0+ so I am still looking for another solution Quote Link to comment Share on other sites More sharing options...
johnsmith153 Posted November 26, 2010 Share Posted November 26, 2010 The most recent comments on php.net are advising how to emulate for pre 5.3. http://php.net/manual/en/function.strstr.php Quote Link to comment Share on other sites More sharing options...
johnsmith153 Posted November 26, 2010 Share Posted November 26, 2010 Same with: http://php.net/manual/en/function.stristr.php Use it to emulate the before_needle php V5.3 : <?php //$h = haystack, $n = needle if($pos=stripos($h,$n)) $string=substr($h,0,$pos); ?> 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.