read string by white spaces in php

i an trying to read a PDF with this library SmalotPdfParserParser(); in laravel 5.6

I am getting all content ok, but i have this:

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

but I need to get the second surname, surname, name, address and phone from these strings… I think that I can get all data count white spaces.

I am trying this:

// 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);

but this return:

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
)

for example, but if i do this:

array_push($secondSurnameArray, $stringDivide[0]);

this return that index 0 it´s not defined.

I need this data to create one array to create insert query.

Thanks for help me, read me and sorry for my english.

update

i hope this:

$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']

after i need to do array merge with $secondSurname, $surname and $name to do insert query

from Newest questions tagged laravel-5 – Stack Overflow https://ift.tt/3hgFNEI
via IFTTT

Related Posts

Codeigniter : Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE) in Laravel project

I’m getting following error: **Parse error: syntax error, unexpected ‘const’ (T_CONST), expecting variable (T_VARIABLE)** Note : It’s working in local but facing issue in production server. private…

Firebase receive notification while tab is active or on focus

What i want is to be able to perform an action when a user receives a notification while the browser is open and tab is active or…

Laravel’s alias loader does not find class

We have a legacy project that we cannot update and we need to make some changes in symfony’s Response.php in vendor. We have solved this by copying…

Laravel 5 – generic document management

I have a system where you can create different types of unique documents. For instance, one document is called Project Identified and this expects certain inputs. Originally,…

Laravel Nova limit the results in indexQuery

I ran intro a situation where I need to limit the results of a resource to only 3 results. To be more specific, based on the logged…

Auditoria en laravel 5.8 [closed]

Cómo puedo automatizar el registro de actividades de un usuario en laravel? Si un usuario ingresa a un app de laravel, debo guardar toda su actividas, a…

Leave a Reply

Your email address will not be published.