doujiao7679 2010-12-18 06:34
浏览 84
已采纳

如何在PHP中从此字符串中提取两个变量

I have a string like this :

oauth_token=1%2F7VDUGD4tKIqSu4jX4DoeCRD1KbqqgTxFnFFliVgbSss&oauth_token_secret=Rk%2FwejMIg6t%2BFphvRd%2BZ5Wkc

How can I extract the two variables oauth_token and oauth_token_secret from the about string using PHP

NOTE: this is not coming from the URL( we can do that using $_GET)

Thank YOU

  • 写回答

4条回答 默认 最新

  • douchen7555 2010-12-18 06:41
    关注

    Use parse_str() for parsing query string parameters.

    // Extract into current scope, access as if they were PHP variables
    parse_str($str);
    echo $oauth_token;
    echo $oauth_token_secret;
    
    // Extract into array
    parse_str($str, $params);
    echo $params['oauth_token'];
    echo $params['oauth_token_secret'];
    

    You may wish to urldecode() the variables after you've extracted them.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 为什么eprime输出的数据会有缺失?
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题