Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I need some help importing the user input from a form I created into a PHP array variable.

<form method="post" action="test.php">
  <input type="text" name="input" />
  <input type="submit">
</form>

And the PHP variable:

$urls = array();

As so the end result after typing a list of links in the following format:

'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=30/03/1150005935/1&judet=30', 'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=30/03/1150005936/1&judet=30', 'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=30/03/1150005937/1&judet=30',

Would be:

$urls = array(
       'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=30/03/1150005868/1&judet=30',
       'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=30/03/1150005868/1&judet=30',
       'http://lmvz.anofm.ro:8080/lmv/detalii.jsp?UNIQUEJVID=30/03/1150005868/1&judet=30',
);

Any Ideas?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can Use explode function:

$post = explode(',', $_POST['text']);
foreach($post as $link) {
    $urls[] = $link;
}

print_r($urls);

More info about the function here https://php.net/explode

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.