This is a rather strange way to get values ββin a list. Therefore, I assume that you are ultimately trying to output from a separate file to an array. In this case, you just do
file('path/to/file');
To read each line into a separate element of the array.
If the file link looks like this:
test list example
If you know the values ββin front of the front, as in your code example, you should just put them in an array and not read them from a string.
If you just have to read values ββfrom a string, I would suggest using the PHP_EOL constant to define line breaks. Like this:
$list = 'test' . PHP_EOL . 'list' . PHP_EOL . 'example'; $list_arr = explode(PHP_EOL, $list);
The PHP_EOL constant will give you a much better platform-independent way of getting values ββthat define your line breaks.
source share