mostafatalebi Posted November 17, 2012 Share Posted November 17, 2012 Hello every one I want to write an extensive database for my upcoming bilingual dictionary. I must make my words in a notepad or a text file, and since this job is done by a typist rather than a programmer, I have to tell her to type in a simple format so that using php, later, I could add them to a database. My approach is that to tell her to type words with one space between. Like: Carrot Potato Bread Water Glass Head Hand Eye Ear Body What PHP Function or regular expression I must use to get each word into a row of a table in a database? Quote Link to comment https://forums.phpfreaks.com/topic/270829-selecting-a-word-in-php-string/ Share on other sites More sharing options...
Barand Posted November 17, 2012 Share Posted November 17, 2012 (edited) explode eg <?php $line = "Carrot Potato Bread Water Glass Head Hand Eye Ear Body"; foreach (explode(' ', $line) as $word) { echo $word . '<br />'; } ?> Edited November 17, 2012 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/270829-selecting-a-word-in-php-string/#findComment-1393180 Share on other sites More sharing options...
mostafatalebi Posted November 17, 2012 Author Share Posted November 17, 2012 Oh very clean indeed, thanks. But a question before embarking on a test. Instead of <br /> is it apt to place a mysqli set of commands? thanks Quote Link to comment https://forums.phpfreaks.com/topic/270829-selecting-a-word-in-php-string/#findComment-1393184 Share on other sites More sharing options...
Barand Posted November 17, 2012 Share Posted November 17, 2012 Yes, you can. I was echoing so you could see the result. Quote Link to comment https://forums.phpfreaks.com/topic/270829-selecting-a-word-in-php-string/#findComment-1393203 Share on other sites More sharing options...
mostafatalebi Posted November 17, 2012 Author Share Posted November 17, 2012 thank you man. working with regular expression are just a way of fun. Quote Link to comment https://forums.phpfreaks.com/topic/270829-selecting-a-word-in-php-string/#findComment-1393241 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.