Skip to content

Instantly share code, notes, and snippets.

@webdevs-pro
Created January 10, 2020 13:52
Show Gist options
  • Save webdevs-pro/000e89f3a9b56532a5445aad9c66bc32 to your computer and use it in GitHub Desktop.
Save webdevs-pro/000e89f3a9b56532a5445aad9c66bc32 to your computer and use it in GitHub Desktop.
php convert text with <br> to JSON format text
<?php
$daily_reading_in_word = get_field('daily_reading_in_word');
$daily_reading_in_word = trim( preg_replace( '/(\r\n)|\n|\r/', '<br/>', $daily_reading_in_word ) );
$daily_reading_in_word = str_replace('<br/>','\r\n',$daily_reading_in_word);
$daily_reading_in_word = str_replace('<br />','',$daily_reading_in_word);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment