jonaofarc Posted November 23, 2008 Share Posted November 23, 2008 so we have a string like 4+1 I just want the 4 isolated from the + and the 1 any ideas? Quote Link to comment Share on other sites More sharing options...
jonaofarc Posted November 23, 2008 Author Share Posted November 23, 2008 any ideas? Quote Link to comment Share on other sites More sharing options...
azuka Posted November 23, 2008 Share Posted November 23, 2008 You're not very specific. Under what conditions would you get a string like that? There are many ways, some regex based, some not. At it's simplest I'd use $text = '4+1'; $text = substr($text, 0, 1); or $text = '4+1'; $text = current(explode('+', $text)); Quote Link to comment Share on other sites More sharing options...
jonaofarc Posted November 23, 2008 Author Share Posted November 23, 2008 thanks azuka , thats all I needed. Quote Link to comment Share on other sites More sharing options...
redarrow Posted November 23, 2008 Share Posted November 23, 2008 This is the correct way ill do it anyway...... <?php $txt="4+1"; $x=preg_replace("/([1]){1}||([4]){1}/",' ',$txt); echo $x; ?> 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.