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? 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 explode eg <?php $line = "Carrot Potato Bread Water Glass Head Hand Eye Ear Body"; foreach (explode(' ', $line) as $word) { echo $word . '<br />'; } ?> 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 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. 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. 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
Archived
This topic is now archived and is closed to further replies.