Pass the html code through JSON



  • Hello!

    There's a html code line on the server. For example:

    $html = '<div class="cats"></div>';
    

    Can these data be sent as JSON?

    When used:

    echo json_encode($html);
    

    Here comes:

    "<\/div>"
    


  • $html = '<div class="cats"></div>';
    $a  = json_encode($html);
    $b = json_decode($a);
    print_r($b);
    

    Out of the variable $b Got it. '<div class="cats"></div>'; Use it on the side of the data. json_decode♪ Checked. http://sandbox.onlinephpfunctions.com




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2