0

I already did my research first, but some topics didn't solve my issue and some quite different from what issue I have. I have a JSON that didn't print out the entire data and as upon checking the culprit is the newline when it was a value (it is my first time knowing it, my bad).

<?php

$jsn = <<<_JSON
{
"name": "Editorial",
"links": "default",
"data": [
    {
        "Status": "Pending",
        "Tags": "Documentation",
        "Info": "all documentation to be ready by Friday"
      
    },
    {
        "Status": "Published",
        "Tags": "Pros and Cons Limits",
        "Info": "documentations about-Realtime\n-Speed per sec\n-API Limit"
       
    }
  ]

   }
 _JSON;
 $data = json_decode($jsn, true);
 $output= $data['links'];
 echo $output;

It will not print any output as the \n was there. So I was planning to do in the future, if they tried to use a newline, I will just temporary change the \n to other characters and decode it back. And that's where I'm having a hard time.

As testing it wasn't working for me.. Converting it back and show in textarea.

$txt = "Documentations about%2Realtime%2Speed per sec%2API Limit";
$value = str_replace("%2", '\n', $txt);
$textArea = '<textarea rows="4">'.nl2br($value).'</textarea>';

echo $textarea;
//output
//documentations about\nRealtime\nSpeed per sec\nAPI Limit

If anyone can help me in your spare time, I really appreciate it.. Thanks in advance.

Maharlikan
  • 63
  • 7

0 Answers0