I need an array to make this:
Hi {nom}, you can buy {var1}
Look like this before being sent:
Hi Manuel, you can buy chips.
I have tried to do this with an array like this:
$(document).on('click','.submitMessage', function(){
prevContent=$('textarea').val();
$variables = array(
'{nom}' => 'Manuel',
'{apl}' => 'García',
'{var1}' => 'chips',
'{var2}' => 'deportes y aventura',
'{var3}' => 'informática y tecnología',
'{cst1}' => 'Serrano, 28',
'{cst2}' => 'Plaza del carmen, 32',
'{cst3}' => 'García Luna, 15'
);
$data = prevContent;
$data = str_replace(array_keys($variables), array_values($variables), $data);
$.post('../actions/newMessage.php',{ms_content:$data});
And this is the error I get on loading the page:

str_replace,array_keys,array_values)?$variables = [{name:'{nom}', value:'Manuel'}, {name:'{apl}', value:'García'}...]