我试图用这个库阅读\Smalot\PdfParser\Parser();
PDFlaravel 5.6
我得到了所有的内容,但我有这个:
Array
(
[0] => MARTIN CARRILLO MARIA ESMERALDA ALHAMBRA 10 958 54 38 93
[1] => ESPIGARES DIAS JOSE ANTONIO ALHAMBRA 11 958 54 33 32
[2] => GUTIERREZ TITOS JOSE MANUEL ALHAMBRA 12 958 54 04 10
[3] => MARTIN COBOS ANTONIO ALHAMBRA 18 958 54 33 28
[4] => GOMEZ CARRILLO JOSE ALHAMBRA 20 958 54 32 72
[5] => RODRIGUEZ RUANO BUENAVENTURA ALHAMBRA 21 958 54 35 86
[6] => GARCIA ARIAS MARIA ISABEL ALHAMBRA 22 958 54 07 87
[7] => RODRIGUEZ JIMENEZ MIGUEL ALHAMBRA 27 958 54 08 77
[8] => GUTIERREZ FERNANDEZ AMANDA HILDA ALHAMBRA 3 958 49 98 62
[9] => DIAZ FLORIAN DOLORES ALHAMBRA 30 958 54 33 99
[10] => PEREZ LASTRA SAUL ADAN ALHAMBRA 32 958 54 31 46
[11] => AMIGO MOLINA MARIA MATILDE ALHAMBRA 35 958 54 31 91
[12] => ESPIGARES GOMEZ JORGE ALHAMBRA 37 958 54 02 22
[13] => ESPIGARES ESPIGARES JOSE ALHAMBRA 40 958 54 31 83
但我需要从这些字符串中获取第二个姓氏、姓氏、姓名、地址和电话……我认为我可以获得所有数据计数空白。
我正在尝试这个:
// loop to get data line
foreach($dataByLine as &$line){
// delete first element in string
$cleanString = substr($line, 0, 7);
$line = str_replace($cleanString, "", $line);
$line = preg_replace('/^[\d]+/','',$line);
//$line = ltrim($line,"0123456789");
$stringDivide = preg_split('/\s+/', $line, -1, PREG_SPLIT_NO_EMPTY);
//array_push($secondSurnameArray, $stringDivide[0]);
array_push($dataList, $line);
}
print_r($dataList);
但是这个回报:
Array
(
[0] => MARTIN
[1] => CARRILLO
[2] => MARIA
[3] => ESMERALDA
[4] => ALHAMBRA
[5] => 10
[6] => 958
[7] => 54
[8] => 38
[9] => 93
)
Array
(
[0] => ESPIGARES
[1] => DIAS
[2] => JOSE
[3] => ANTONIO
[4] => ALHAMBRA
[5] => 11
[6] => 958
[7] => 54
[8] => 33
[9] => 32
)
Array
(
[0] => GUTIERREZ
[1] => TITOS
[2] => JOSE
[3] => MANUEL
[4] => ALHAMBRA
[5] => 12
[6] => 958
[7] => 54
[8] => 04
[9] => 10
)
例如,但如果我这样做:
array_push($secondSurnameArray, $stringDivide[0]);
这将返回未定义的索引 0。
我需要这些数据来创建一个数组来创建插入查询。
谢谢你的帮助,读了我,对不起我的英语。
更新
我希望这:
$secondSurname = ['MARTIN', 'ESPIGARES', 'GUTIERREZ'....etc]
$surname = ['CARRILLO', 'DIAS', 'TITOS', .....etc]
$name = ['JOSE', 'JOSE', 'ANTONIO']
$addres = ['ALHAMBRA 10', 'ALHAMBRA 11', 'ALHAMBRA 12', etc]
$phone = ['958 54 38 93', '958 54 33 32', '958 54 04 10']
在我需要做数组合并之后$secondSurname, $surname and $name
做插入查询