M
M
Maxim Iralov2021-07-27 17:18:56
PHP
Maxim Iralov, 2021-07-27 17:18:56

How to get a substring from a php string?

Hello! I can’t set substrings from a string up to a certain character in any way. It seems that regular expressions should be used here, but something doesn’t go wrong.
I have a string, it's not JSON, because then there is arbitrary text, and then again something similar to a string. The main thing is that it is a STRING!

There is a long line

$str = '...... text": "{\"sender\":null,\"recipient\":null,\"stateCode\":null,\"results\":[{\"applicationID\":\"цуцуцу-affb-4406-a536-8e7129e55fb0\",\"regNumb\":\"0001.001521/2021-0000005\",\"regDate\":\"2021-07-01\",\"appealPurpose\":\"Назначение\",\"appealType\":\"Через ЕПГУ\",\"nameSSM\":\"Выплата 1",\"category\":\"\",\"socialNum\":\"2222222\",\"lastName\":\"Каплин\",\"firstName\":\"Сергей\",\"middleName\":\"Евгеньевич\",\"verdict\":\"REGISTERED\"},{\"applicationID\":\"adsadasd-485c-4118-82f8-3fcf46bb87eb\",\"regNumb\":\"0wwwww001.001521/2021-ввывыы\",\"regDate\":\"2021-07-01\",\"appealPurpose\":\"Назначение\",\"appealType\":\"Через\",\"nameSSM\":\"Выплата",\"category\":\"\",\"socialNum\":\"222222222\",\"lastName\":\"Карпова\",\"firstName\":\"Евгения\",\"middleName\":\"Мадридова\",\"verdict\":\"REGISTERED\"},{\"applicationID\":\"e4288aa9-вфцвцфв-4118-82f8-фцвфцвф\",\"regNumb\":\"фцвцфвфцв/2021-фцвцфв\",\"regDate\":\"2021-07-01\",\"appealPurpose\":\"Назначение\",\"appealType\":\"Через \",\"nameSSM\":\"Выплата 1....................';


It is necessary to extract from such a string all the full name (lastName, firstName, middleName) .. and put it into an array

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2021-07-27
@kapelka001

this "string" is torn out of the original JSON file in the same barbaric way that you are now trying to "parse" it.
JSON must be parsed with standard tools, and not picked with a stick with a nail at the end.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question