first, i have a text file
Samsung|us|new
iPhone|china|new
i want to convert the text file, and the result must be like this
[
[
'Samsung', 'us', 'new'
],
[
'iPhone', 'china', 'new'
]
]
i have already try this, but the code only return one array
code:
<?php
$a = file_get_contents("text.txt");
$b = explode('|', $a);
result:
[
'Samsung','us','new','iPhone','china','new'
];
file()(if your file isn't too big).