Does single or double quote matter in str_ireplace in PHP ?
- by Richards
Hi,
I've to replace newline (\n) with & in a string so that the received data could be parsed with parse_str() into array. The thing is that when I put \n in single quote it somehow turns out as to be replaced with a space:
str_ireplace(array('&', '+', '\n'), array('', '', '&'), $response)
"id=1 name=name gender=gender age=age friends=friends"
But when I put \n in double quotes then it works just fine:
str_ireplace(array('&', '+', "\n"), array('', '', '&'), $response)
"id=1&name=name&gender=gender&age=age&friends=friends"
Why is that so?