I encountered a problem during exploding data from file. My file looks like
04-21-1991 9:09 58 10004-21-1991 9:09 33 00904-21-1991 9:09 34 01304-21-1991 17:08 62 11904-21-1991 17:08 33 00704-21-1991
I'd like to explode data from it like
04-21-1991 9:09 58 100
04-21-1991 9:09 33 009
04-21-1991 9:09 34 013
04-21-1991 17:08 62 119
04-21-1991 17:08 33 007
what i did till now is obtaining an array ( numbers are different, becouse file is different, but structure is the same)
array(1) {
[0]=>
array(901) {
[0]=>
string(10) "07-21-1990"
[1]=>
string(5) "06:43"
[2]=>
string(2) "58"
[3]=>
string(14) "202
07-21-1990"
[4]=>
string(5) "07:03"
[5]=>
string(2) "33"
[6]=>
string(12) "4
07-21-1990"
and here is my code
header("Content-type:text/plain");
$file = fopen("data/data-03", "r");
$result = array();
$file = explode(" ", file_get_contents("data/data-03"));
foreach ( $file as $content )
{
$result[] = array_filter(array_map("trim", explode(" ", $content)));
}
var_dump($result);
preg_match_allinstead of a crude explode.