How to escape single quotes in a translated array
Luc last edited by Luc
Can anyone tell me how to escape the single quotes in a variable for the returned translated array?
Apparently it isn't working with a backslash like this:
$pages = 'Pagina\'s'; return [ 'pages' => $pages, ]
nor does it work with double quotes
$pages = "Pagina\'s"; return [ 'pages' => $pages, ]
ghermans last edited by
Try to use the php function addslashes()
<?php $pages = "Pagina's"; $array = [ 'pages' => addslashes($pages), ]; print_r($array);
This will return
Array ( [pages] => Pagina\'s )
Luc last edited by
$currencies = "Valuta's"; $locales = "Talen"; return [ 'currencies' => addslashes($currencies), 'currencies-and-locales' => addslashes($currencies) . ' en ' . $locales ]
It doesn't always give the same results as you can see in the screenshot.
We get "Valuta's" and "Valuta's en Talen"