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.

4 Years
Discussion Span
Last Post by ariffin246

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.