有人请帮帮我......
My CORD
<select name="tables">
<?php if(!empty($_POST['tables'])){
echo "<option>$_POST[tables]</option>";
}else{
echo "<option>Select</option>";
}
?>
<option value="vehisys_vehicles">Vehicles</option>
<option value="vehisys_staff">Staff</option>
<option value="vehisys_maintain">Maintain</option>
</select>
发布此线后,它返回选项值(vehisys_vehicles)。
如何在框中显示选项(车辆)。
感谢。
答案 0 :(得分:0)
我会explode
_
$arrTables = explode("_", $_POST['tables']);
echo "<option>". $arrTables[1] ."</option>";
答案 1 :(得分:0)
有很多方法可以实现这一目标。
使用strpbrk
:
$result = strpbrk($value, '_');
使用sscanf
:
sscanf($value, '%[^_]_%s', $pre, $result);
使用explode
:
$parts = explode('_', $value, 2);
$result = $parts[1];
使用regex:
$result = preg_replace('/^[^_]+_(.+)/', '$1', $value, 1);
或
preg_match('/^[^_]+_(.+)/', $value, $matches);
$result = $matches[1];
使用strpos
:
$result = substr($value, strpos($value, '_')+1);
使用strstr
:
$result = substr(strstr($value, '_'), 1);