开发者

how to parse $_REQUEST?

here i am checking for and getting part of the request, (the ids). i also print out the entire request:

if (isset($_REQUEST['ids'])){
    $amount = sizeo开发者_如何学Pythonf($_REQUEST['ids']);
    print_r($_REQUEST);
    echo "<br>$amount invitations Successfully Sent";
}

this is how the entire $_REQUEST prints out:

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\"
)

i need to parse the part at the end: &uid=100000664203700, specifically '100000664203700'


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


parse_str() will break up things that look like a query string. I recommend you pass an array as the second parameter.


You can use parse_str()—it should do the trick.


First, remove the \" (using a combination of preg_replace and stripslashes) at the beginning and the end, then use parse_str:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜