A
A
Anastasia2020-07-04 00:28:38
PHP
Anastasia, 2020-07-04 00:28:38

How to get the full name from the line, b. and number?

Hello. There is such a line:
Ivanov Ivan Ivanovich 01.01.1970 353

Please tell me how can I separately get data into these variables?
$lastname $firstname $
secondname
$birthdate
$
number

There may not be a patronymic, so explode doesn't really suit me... I would gladly use it.

In general, it would probably be possible to explode, and then just check whether the 3rd or 4th element of the array is a date, and get the number through end($array). I just don't know what will be faster: regExp or such a crutch.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Osher, 2020-07-04
@nastya97core

https://regex101.com/r/DrokUH/1

^(\w+\s\w+(?:\s\w+)?)\s(\d{2}\.\d{2}\.\d{4})\s(\d+)$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question