Arnold Porche Villaluz
Arnold Porche Villaluz

Reputation: 213

Separate data into 3 fields

In my form: I have 8 checkboxes that will save to MySQL as a string/varchar (not an int).

Ex:

Now, I want to output this to 3 different fields with limited number of characters per field.

If all checkboxes are check and save into MySQL, the output will be:

I did some research on STRLEN, EXPLODE, etc. and somehow I can't put this together in PHP. How could I do it?

Upvotes: 0

Views: 117

Answers (1)

Brent Baisley
Brent Baisley

Reputation: 12721

Perhaps wordwrap will do the trick? One way of doing it is (not tested):

$string_list = explode("\n", wordwrap($string, 25));
$field1 = array_shift($string_list);
$string = implode(" ",$string_list);

$string_list = explode("\n", wordwrap($string, 30));
$field2 = array_shift($string_list);

$field3 = implode("\n", $string_list);

Upvotes: 2

Related Questions