First off, I have seen the following questions already:
- Php - explode a string with two delimiters
- explode an array of delimited strings into two arrays
- PHP explode/split with 2 different delimiters
And more. If I have an input like this:
A@B#C
a@b#c
For each line, I have the two delimiters @
and #
, I would like to have them separated as an array this way:
Array
(
[0] => A
[1] => B
[2] => C
)
Array
(
[0] => a
[1] => b
[2] => c
)
I have the looping code this way:
foreach (explode(PHP_EOL, $input) as $line) {
$line = explode("@", $line);
$line[1] = explode("#", $line[1]);
}
I know what I am doing is wrong. The output I get is:
Array
(
[0] => A
[1] => Array
(
[0] => B
[1] => C
)
)
Array
(
[0] => a
[1] => Array
(
[0] => b
[1] => c
)
)
I am out of ideas to think anything else, so, can someone please guide me on how to split the string inside the same array? ps: I don't wanna use regex!