json_encode issue

Discussion in 'PHP' started by Jeremy Benson, Apr 5, 2019.

  1. #1
    Hello,

    I've started back into my game project. Right now I'm facing an issue between php, js, and mysql. I have room descriptions as text field in mysql. They have paragraphs right the field, copied from text editor to mysql. When I var_dump the return html I see a line for each paragraph out of mysql.

    issue image
    https://ibb.co/WWHj0bc

    When I run this line of code to clean white spaces, not what I want to do, it still json_encode's wrong:

     $returnValue['html'] = '<h2>'.$returnValue['roomData']['name'].'</h2><p>'.trim(preg_replace( "/[\\x00-\\x19]+/" , '' , $returnValue['roomData']['description'])).'</p>';
    
    Code (markup):
    I really want to preserve my paragraphs. I think it's json encoding wrong because I just alert blank in JS instead of [Object][object] or whatever it is.

    See my awesome game window :)
    https://ibb.co/2tSDH3d
     
    Jeremy Benson, Apr 5, 2019 IP
  2. Jeremy Benson

    Jeremy Benson Well-Known Member

    Messages:
    364
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    123
    #2
    Uh, this thread can be marked for deletion. I found the issue. A hidden typo in another location. Sorry for inconvenience here.
     
    Jeremy Benson, Apr 5, 2019 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #3
    Just a silly question on my part...

    [\\x00-\\x19]+

    Why are you deleting ALL control characters? I'm just curious the reasoning of using that over \s.
     
    deathshadow, May 23, 2019 IP