nobodyk Posted April 6, 2010 Share Posted April 6, 2010 Ok, I'm trying to validate if the user enter the right information, and then enter it in the db. For example, the user enters: truck, car, wheel, fast so the user is only allowed to enter letters, numbers, spaces, and commas In the code I want to be able to get each word separated and insert each word into the database. So the data base would look like this: Row Word 01 truck 02 car 03 wheel 04 fast I know I would have to use a for loop, here's my pseudo code: //Get string from user input $uWord // = truck, car, wheel, fast //Count Number of Words to use as an index for the loop $uCount // = 4 Start For Loop //Get First Word $TempWord // = truck Insert word into DB //Remove first word from string $uWord // = car, wheel, fast End Loop What do you guys think? Can someone guide me in the right direction. Thanks. Link to comment https://forums.phpfreaks.com/topic/197811-need-help-with-strings-and-for-loops/ Share on other sites More sharing options...
teamatomic Posted April 6, 2010 Share Posted April 6, 2010 uwords words=explode(",",uwords) foreach words as word insert word HTH Teamatomic Link to comment https://forums.phpfreaks.com/topic/197811-need-help-with-strings-and-for-loops/#findComment-1038059 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.