I have a text field.
In hooks (before update) i want to put every line of the text field in an element of an array.
I tried using:
$Stem_arr = explode("\n", $data['Knd']);
This did not work.
Splitting a text field into an array
Re: Splitting a text field into an array
Is the field Knd set as a text area or a rich text area?

- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.
- Need personalized consulting on your specific app and customizations? Book an online call with me here.
Re: Splitting a text field into an array
The field is set as a text area.
Re: Splitting a text field into an array
If \n doesn't work, try <br>
Code: Select all
$Stem_arr = explode("<br>", $data['Knd']);

- DataTalk is an innovative AppGini plugin based on ChatGPT that allows you to interact with your AppGini database using natural language questions, without writing any SQL. Check the demo video
- Check our other plugins and get a generous discount of up to 30% when buying 2 or more plugins.
- Need personalized consulting on your specific app and customizations? Book an online call with me here.
Re: Splitting a text field into an array
$Stem_arr = explode("<br>", $data['Knd']);
did not work.
I found out that in my case the following statement did work:
explode("r", $data['Knd']);
In my text field there are only numbers, otherwise this would be not usefull.
did not work.
I found out that in my case the following statement did work:
explode("r", $data['Knd']);
In my text field there are only numbers, otherwise this would be not usefull.
Re: Splitting a text field into an array
Problem solved.
1] find out which characters are used for return new line:
$hlp=bin2hex(".........") for the dots you copy two short lines in the text field for example
A
A
Print $hlp: yoy can see which characters are used for A en in between the characters for return newline
(in my example with utf8: hex 5c725c6e).
2] put the characters in a variable for return new line:
$r=hex2bin("5c725c6e");
3] Now you can explode a text field with:
explode($r,$data['Stem']);
Stem is the name of the text field.
1] find out which characters are used for return new line:
$hlp=bin2hex(".........") for the dots you copy two short lines in the text field for example
A
A
Print $hlp: yoy can see which characters are used for A en in between the characters for return newline
(in my example with utf8: hex 5c725c6e).
2] put the characters in a variable for return new line:
$r=hex2bin("5c725c6e");
3] Now you can explode a text field with:
explode($r,$data['Stem']);
Stem is the name of the text field.