0

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?

0

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.