Ini kod asal saya:
<?php
/**
* Permintaan pos
*
* @param string $url address
* @param array $headers Http Header
* @param string $body content
* @return string
*/
siaran fungsi($url, $headers, $body) {
$ch = curl_init ();
curl_setopt ($ ch, curlopt_ssl_verifypeer, false);
curl_setopt ($ ch, curlopt_url, $ url); palsu) ch );
curl_close($ch);
return $response;
}
// Sila log masuk dan pergi ke "Workbench-Account Settings-Developer Information" untuk melihat x-ti-app- id//x-ti-app-id dalam kod sampel bukan data sebenarconst APP_ID = '9d285d1c896';// Sila log masuk dan pergi ke "Workbench-Account Settings-Developer Information" untuk melihat x-ti-secret -code//x-ti-secret-code data bukan sebenar dalam kod sampel
const SECRET_CODE = '7be1f6203f';
// Pengecaman borang am
const URL = 'https: //api.textin.com /ai/service/v2/recognize/table';
$headers = [ 'x-ti-app-id:' , 'x-ti-. secret-code:' . SECRET_CODE ];$fileData = file_get_contents('123.png', false, stream_context_create([
'http' => ]
]));
URL, $headers, $fileData);$ocrResult = json_decode($response, true);function displayTable($table) {
echo "<table border='1'>";
foreach ($table as $row) {
" <td>" $cell[0]['text'] . "</td>"; ;";
}
$table = $ocrResult['result']['tables'][0]['table_cells'];
displayTable($table);
array(5) { ["kod"]=> int(200) ["mesej"]=> rentetan(7) "kejayaan" ["tempoh"]=> int(289) ["hasil"]=> tatasusunan(4) { ["sudut"]=> int(0) ["ketinggian"]=> int(219) ["jadual"]=> tatasusunan(1) { [0]=> tatasusunan(8) { ["ketinggian_baris"]=> tatasusunan(6) { [0]=> int(46) [1]=> int(17) [2]=> int(29) [3]=> int(32) [4]=> int(20) [5]=> int(20) } ["type"]=> rentetan(15) "table_with_line" ["table_cells"]=> tatasusunan(55) { [0]=> tatasusunan(8) { ["end_row"]=> int(0) ["sempadan"]=> tatasusunan(4) { ["kanan"]=> int(-1) ["bawah"]=> int(-1) ["kiri"]=> int(-1) ["atas"]=> int(-1) } ["kedudukan"]=> tatasusunan(8) { [0]=> int(1) [1]=> int(49) [2]=> int(635) [3]=> int(49) [4]=> int(635) [5]=> int(95) [6]=> int(1) [7]=> int(95) } ["end_col"]=> int(11) ["start_row"]=> int(0) ["start_col"]=> int(0) ["garisan"]=> tatasusunan(1) { [0]=> tatasusunan(7) { ["sudut"]=> int(0) ["teks"]=> rentetan(6) "宋体" ["arah"]=> int(1) ["tulisan tangan"]=> int(0) ["kedudukan"]=> tatasusunan(8) { [0]=> int(7) [1]=> int(60) [2]=> int(29) [3]=> int(60) [4]=> int(29) [5]=> int(73) [6]=> int(7) [7]=> int(73) } ["skor"]=> float(0.845) ["type"]=> rentetan(4) "teks" } } ["teks"]=> rentetan(6) "宋体" } [1]=> tatasusunan(8) { ["end_row"]=> int(1) ["sempadan"]=> tatasusunan(4) { ["kanan"]=> int(-1) ["bawah"]=> int(-1) ["kiri"]=> int(-1) ["atas"]=> int(-1) } ["kedudukan"]=> tatasusunan(8) { [0]=> int(2) [1]=> int(95) [2]=> int(26) [3]=> int(95) [4]=> int(26) [5]=> int(112) [6]=> int(2) [7]=> int(112) } ["end_col"]=> int(0) ["start_row"]=> int(1) ["start_col"]=> int(0) ["garisan"]=> tatasusunan(0) { } ["teks"]=> rentetan(0) "" } [2]=> tatasusunan(8) { ["end_row"]=> int(1) ["sempadan"]=> tatasusunan(4) { ["kanan"]=> int(-1) ["bawah"]=> int(-1) ["kiri"]=> int(-1) ["atas"]=> int(-1) } ["kedudukan"]=> tatasusunan(8) { [0]=> int(26) [1]=> int(95) [2]=> int(84) [3]=> int(95) [4]=> int(84) [5]=> int(112) [6]=> int(26) [7]=> int(112) }["end_col"]=> int(1) ["start_row"]=> int(1) ["start_col"]=> int(1) ["garisan"]=> tatasusunan(1) { [0]=> tatasusunan(7) { ["sudut"]=> int(0) ["teks"]=> rentetan(1) "A" ["arah"]=> int(0) ["tulisan tangan"]=> int(0) ["kedudukan"]=> tatasusunan(8) { [0]=> int(49) [1]=> int(100) [2]=> int(61) [3]=> int(100) [4]=> int(61) [5]=> int(112) [6]=> int(49) [7]=> int(112) } ["skor"]=> float(0.849) ["type"]=> rentetan(4) "teks" } } ["teks"]=> rentetan(1) "A" } [3]=> tatasusunan(8) { ["end_row"]=> int(1) ["sempadan"]=> tatasusunan(4) { ["kanan"]=> int(-1) ["bawah"]=> int(-1) ["kiri"]=> int(-1) ["atas"]=> int(-1) } ["kedudukan"]=> tatasusunan(8) { [0]=> int(84) [1]=> int(95) [2]=> int(150) [3]=> int(95) [4]=> int(150) [5]=> int(112) [6]=> int(84) [7]=> int(112) } ["end_col"]=> int(2) ["start_row"]=> int(1) ["start_col"]=> int(2) ["garisan"]=> tatasusunan(1) { [0]=> tatasusunan(7) { ["sudut"]=> int(0) ["teks"]=> rentetan(1) "B" ["arah