RobboSan Posted December 6, 2007 Share Posted December 6, 2007 Hi there I was wondering if anyone could help me with a program I'm trying to write. What I want it to do is: have a user input text (through a form) Then have all the quotes ("lalala") from that text displayed ex. This is the text that "was entered" in the form. All I want to show up after the user enters the text is: "was entered" I have some work on it done but I'm too new at PHP to even know if it is worth going in the direction I'm heading in. If anyone know an easy way to do this it would be greatly appreciated. If not, sorry to bother you Quote Link to comment https://forums.phpfreaks.com/topic/80533-grabbing-quotes-from-a-text/ Share on other sites More sharing options...
GingerRobot Posted December 6, 2007 Share Posted December 6, 2007 Regular expressions are your friend: <?php $str = 'This is the text that "was entered" in the form. More "text entered".'; preg_match_all('|"(.*?)"|',$str,$matches); foreach($matches[1] as $v){ echo 'Quote: '.$v.'<br />'; } ?> Regular expressions allow you to match/find/replace specific text against general patterns. There's a subform here which might help you understand a bit about them, or you can google. Quote Link to comment https://forums.phpfreaks.com/topic/80533-grabbing-quotes-from-a-text/#findComment-408336 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.