Answer the question
In order to leave comments, you need to log in
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
php.net/manual/ru/function.preg-replace.php
And the regular expression is something like this - https://regex101.com/r/cD8rF8/1
$output = /* сюда засовуем вывод */
$outputArray = explode('--', $output);
$clearResult = $outputArray[0]; // $clearResult - будет содержать только JSON вне зависимости выводился после него хеш или нет
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question