Created
April 16, 2020 18:46
-
-
Save isotrope/7f452b2ec0ffbb1b3189c1dab5c2dbb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$my_var = 'Something | |
on multiple | |
lines'; | |
$cleaned_var = str_replace( [ "\r", "\n", chr( 10 ), chr( 13 ) ], '', $my_var ); | |
// comme Oleg dit, juste au cas où tu te bats contre des quotes | |
$cleaned_var = str_replace('"', '"', $cleaned_var); | |
?> | |
<script> | |
var jsVar = "<?php echo $cleaned_var; ?>"; | |
console.log( jsVar ); | |
</script> | |
<?php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment