A
A
Alexey2015-11-06 14:15:42
PHP
Alexey, 2015-11-06 14:15:42

How to remove extra at the end of a file?

Hello, the answer comes to the file in the form of json, but for some reason at the end of the file I emphasize SOMETIMES Boundary is added (I send it from the POST program with a request). How to analyze using php whether this line exists, if so, delete it?
The answer comes like this

{
"DATE": "2015-11-05",
"array": [
{
"ERR_ID": "24",
"ERR_MSG":"Сообщение"
},
{
"ERR_ID": "25",
"ERR_MSG":"Сообщение"
},
{
"ERR_ID": "26",
"ERR_MSG":"Сообщение"
}
]
}--7d50cdce88074cd4a63c326081993246 -> Вот эта строчка

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrew, 2015-11-06
@alexeyshi

php.net/manual/ru/function.preg-replace.php
And the regular expression is something like this - https://regex101.com/r/cD8rF8/1

I
inDeepCode, 2015-11-06
@inDeepCode

$output = /* сюда засовуем вывод */
$outputArray = explode('--', $output);
$clearResult = $outputArray[0]; // $clearResult - будет содержать только JSON вне зависимости выводился после него хеш или нет

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question