Get Text From Tag Using PHP

In order to get both the label and the value using just PHP, you need to have both arguments as part of the value.

For example:

<select name="make">
    <option value="Text:5"> Text </option>
</select>

PHP Code

<?php
$parts = $_POST['make'];
$arr = explode(':', $parts);

print_r($arr);

Output:

Array(
  [0] => 'Text',
  [1] => 5
)

This is one way to do it.

Leave a Comment