I am clueless on how to separate the value of a HTML TextBox into separate characters before inserting into database.

The user will key in certain form of code in the textbox. EG:JYX. The code needs to be separated and assigned to variable for each of the character before being inserted into the database.

Anyone have tips on how to solve this issue.

Recommended Answers

All 5 Replies

What do you mean separating the values?

Lets say the user post a code, something like ABC in the text box. I need to spilt the value of ABC into:

$a = 'A'; 
$b = 'B';
$c = 'C';

Then insert the code into database. I am only confused with part of separating the input value from the user.

You can use str_split(). And extract, except that extract will skip non php strandard variable. You can just run through the array and assign a key on each value. Let me know if you got this, I'll be happy to create an example if you want to.

skip non php strandard variable

What I mean by this, str_split produces numerical array. So if you're going to put it to extract, it'll be disregarded.

But then, it'll take time extracting all the value. you can just use str_split alone, to optimize your code, and put all splitted value in the database.


I'll be happy to create an example if you want to.

It would be great if you can provide some code snippets, to help me understand better. Thanks in advance

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.