Code: Select all
//I have a multiline string. lets say.
$str = <<<EOS
php
is a
great
serverside
language
EOS;
echo '<input type="button" onlick=javascript:function("'.$str.'"); />';for this i have to relpace all multiline charachers so that the javascript function parameter string should look like.
Code: Select all
"php"+
"is a"+
"great"+
"serverlide"+
"language"
Code: Select all
preg_replace('/\n/',' "+\n" ',$str);
or
preg_replace('/\n/',' ',$str);
or
preg_replace('/\s/',' ',$str);i tried '\r' , '\r\n' also instead of \n but no use any help