Created
August 29, 2018 12:19
-
-
Save ammarfaizi2/a155926ad1f0d782892b26a938e8b8d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$out = file_get_contents("hasil.tmp"); | |
if (preg_match_all( | |
"/(?:<td style=\".+left;\">)(.*)(?:<\/td>.+<td id=desc.+>)(.*)(?:<.+<td.+>)(.*)(?:<\/td>.+<td.+>)(.*)(?:<)/Usi", | |
$out, | |
$m | |
)) { | |
$data = []; | |
array_walk($m[1], function ($v, $key) use ($m, &$data) { | |
$m[2][$key] = trim(html_entity_decode($m[2][$key], ENT_QUOTES, "UTF-8")); | |
$m[3][$key] = trim(html_entity_decode($m[3][$key], ENT_QUOTES, "UTF-8")); | |
$m[4][$key] = trim(html_entity_decode($m[4][$key], ENT_QUOTES, "UTF-8")); | |
$data[] = [ | |
"date" => $v, | |
"description" => $m[2][$key], | |
"amount" => strip_tags($m[3][$key]), | |
"transaction_type" => (preg_match("/td/", $m[3][$key]) ? "kredit" : "debet") | |
]; | |
}); | |
unset($m); | |
header("Content-Type: text/plain"); | |
print_r($data); | |
} else { | |
print "Error!"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment