1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

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.
    SEMrush
    See my awesome game window :)
    https://ibb.co/2tSDH3d
     
    Jeremy Benson, Apr 5, 2019 IP
    SEMrush
  2. Jeremy Benson

    Jeremy Benson Active Member

    Messages:
    347
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    73
    #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:
    8,926
    Likes Received:
    1,625
    Best Answers:
    232
    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