从URL拆分数据?

Say my url is site.php?id=X-34837439843

How do i split it so I return

$table = "X";
$id = "X-34837439843";

Basically I'm using the same page to select from different tables, and the letter at the beginning of the ID represents which table, so I need to split the left side of the "-".

Simple - use list and explode:

list($table, $id) = explode('-', $_GET['id']);
$id = $table . '-' . $id;

codepad example

Try this, after splitting the values are stored in array format in $regs

<?php
$str = $_GET['id'];

ereg("-",$str,$regs);
print_r($regs);

?>

The canonical method for portioning strings is:

$table = strtok($_GET["id"], "-");
$id = strtok("-");