2010-12-02 31 views
0

这里我正在检查和获取部分请求(ID)。我还打印出整个请求:

if (isset($_REQUEST['ids'])){ 
    $amount = sizeof($_REQUEST['ids']); 
    print_r($_REQUEST); 
    echo "<br>$amount invitations Successfully Sent"; 
} 

这是怎样的整个$ _REQUEST打印出:

Array 
(
    [mfs_typeahead_req_form_4cf74f96db3688507476560] => Start Typing a Name 
    [ids] => Array 
     (
      [0] => 510149460 
     ) 
    [fbs_258181898823] => \"access_token=258181898823|2.q_qb_yoReO0_xc4H8PxKRQ__.3600.1291280400-100000664203700|LqtGr_OiJTASGmek61awxmxfvFk&expires=1291280400&secret=85eTEELZj8lkV82V_PwRSA__&session_key=2.q_qb_yoReO0_xc4H8PxKRQ__.3600.1291280400-100000664203700&sig=d4cc0e4c0992ea29c0adfd60dc27185b&uid=100000664203700\" 
) 

我需要在端部来解析部分:& UID = 100000664203700,具体“100000664203700 '

+0

你可以用的preg_match http://php.net/manual做/en/function.preg-match.php – 2010-12-02 18:24:50

+0

这里不要使用`$ _REQUEST`。请参阅http://stackoverflow.com/questions/368329/php-using-get-post-instead-of-request – Lekensteyn 2010-12-02 18:32:30

回答

0

parse_str()将分解看起来像查询字符串的东西。我建议你传递一个数组作为第二个参数。

1
$queryString = $_REQUEST["fbs_258181898823"]; 
$output = array(); 
parse_str($queryString, $output); 
print $output["uid"]; 
0

首先,删除\"(使用preg_replace和组合stripslashes)在开始和结束,然后使用parse_str

$str = preg_replace('/(^"|"$)/', '', stripslashes($_REQUEST['fbs_258181898823'])); 
parse_str($str, $data); 
$uid = $data['uid'];