Jump to content

Recommended Posts

I'm trying to create a form that would batch process data rather than using one form to submit multiple entries.

 

I'm having trouble just splitting the data between each line. I've tried two different ways so far and neither do what I want. Right now I'm just trying to split each line into an array element. I'm taking it in steps.

 

First way:

/* Batch button */
if (isset($_POST['BatchSubmit']) && $_POST['BatchSubmit'] == 'Add')
{
foreach ($_POST as $key => $val) { $_POST[$key] = makeSafe(trim($val)); }

$batch = $_POST['batch'];
$lines = explode("\r\n", $batch);
print_r($lines);
}

 

Second way:

/* Batch button */
if (isset($_POST['BatchSubmit']) && $_POST['BatchSubmit'] == 'Add')
{
foreach ($_POST as $key => $val) { $_POST[$key] = makeSafe(trim($val)); }

$batch = nl2br($_POST['batch']);
$lines = explode('<br />', $batch);
print_r($lines);
}

 

Any help with a function I should look at? Thanks.

I don't know why it's working now, but it is. Maybe it's the single quotes. Before I was using double.

$lines = explode('\r\n', $batch);

 

The issue I'm having now is when there's an error, I output the input back into the textarea. However, it inserts \r\n into the text.

 

How can I get it to display exactly how it was inputted?

Are you saying I should NOT use single quotes? It didn't explode properly when I did use double quotes. It works as wanted when I use single. When I pull the information from the $_POST array, it has those literal characters in it.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.