2016-11-25 03:08
浏览 43


I have a problem with my code, i have this code that create image from external source of image & string. I used json to get the string.

My problem is if i used the string from json data i could not get the proper wrapping of string like this:

            $url = '';

            $JSON = file_get_contents($url);
            $data = json_decode($JSON);
            $string  = $data->text;

But if i declare and set string directly i got the output that i want like this:

$string = "Enter into his gates with thanksgiving, and into his courts with praise: be thankful unto him, and bless his name. For the Lord is good; his mercy is everlasting; and his truth endureth to all generations.";

I dont think the error or the problem is on the code for wrapping the text on my image. I think it is on the json data. How can i fix this?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dragon4808 2016-11-25 04:09

    The text has symblols. Just replace them:

    $string = preg_replace("/
    /", ' ', $data->text);

    or without a regular expression:

    $string = str_replace("
    ", ' ', $data->text);
    点赞 评论

相关推荐 更多相似问题