Jump to content

need help with strings and for loops


nobodyk

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.