How to split text from a jquery post into an array
<p>I have a textarea that I want the user to be able to enter variables into (one variable per line). When they click submit I then send what they've entered with a jQuery post to a php script like so:</p>

<pre><code>$('#submit').click(function() {
   variables = $('#variables').val();
   $.post('script.php', { "variables": variables }, function(data) {

   }, 'json');
});
</code></pre>

<p>I recieve the string ok in the script easily with:</p>

<pre><code>$variables = $_POST['variables'];
</code></pre>

<p>but how would I split this string of variables into an array? I have tried:</p>

<pre><code>$variableList = explode("\r\n", $variables);
preg_replace("\r\n", '&lt;br /&gt;', $variables);
str_replace("\r\n", '&lt;br /&gt;', $variables);
</code></pre>

<p>Can anyone help please?</p>
