0

In php i would like to put a string like that :

*1\t1\tSomejehjdbsj\t7\t10\t5\t10\t0\t0\t0\t0\t0\t0\t--:--\t0\t0\t0\t0\t0\t00:00:00\t0\t1\t0\t0\t1f7ef741\t15:42\t99\t1026\t1\t--:--\tShowVault\t0\t1f7ef74187664f03876538511f30a5af\tSomejehjdbsj\t0\t0\t00000000000000000000000000000000\t\t00000000000000000000000000000000\t00000000000000000000000000000000\t0\t0\tNC-Series\t1\t12\tSCOPE\t16\t-1\t0\t0\t0\t0\t0\t0\t0\t0\t0\t\t0\t\t\n"]}*

But each \t split my string and its differents values. And the \n is another "row" of that kind of stuff. I need those values so i thinks i could put it in an array, But i don't know how to do that. thanks!

7
  • do you want to split a string by either \t OR \n into a single array? Commented Feb 15, 2017 at 15:03
  • in fact both, In the \n spliter i've got other \t spliter Commented Feb 15, 2017 at 15:04
  • imagine a box in a box Commented Feb 15, 2017 at 15:04
  • show the approximate expected result, at least a part of them Commented Feb 15, 2017 at 15:05
  • if i understand what you are saying, first explode on \n into array, then loop thru that array and explode each line by \t php.net/manual/en/function.explode.php Commented Feb 15, 2017 at 15:06

1 Answer 1

1

Try something like this:

$testString = 'AAA\tBBB\nCCC\tDDD';

$result = explode('\\t', $testString);
foreach ($result as $key => $current) {
    if (strpos($current, '\\n')) {
        $result[$key] = explode('\\n', $current);    
    }
}
var_dump($result);

See it in action here: https://3v4l.org/92ttB

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.