dongyan6503 2011-12-28 22:29
浏览 38
已采纳

array_shift和explode有效吗?

I wonder if they disabled array_shift in > PHP 5.2.6

$realid = array_shift(explode("-", $id));

Because this code was working fine on my server PHP Version 5.2.6, while is not working in another server with higher PHP version.

If so, is there anyway I can do the following:

For a URL like this 87262-any-thing-here.html how can I get only the number, 87262, so that I will use it to call any entry from database:

$qryrec="select * from mytable where id='$realid'";
$resultrec=mysql_query($qryrec) or die($qryrec);
$linerec=mysql_fetch_array($resultrec);

Is there any way to do the same without array_shift?

  • 写回答

2条回答 默认 最新

  • dongyuxiao6295 2011-12-28 22:36
    关注

    Use

    $realid = explode("-", $id);
    $realid = $realid[0];
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 深度学习残差模块模型
  • ¥20 两个不同Subnet的点对点连接
  • ¥50 怎么判断同步时序逻辑电路和异步时序逻辑电路
  • ¥15 差动电流二次谐波的含量Matlab计算
  • ¥15 Can/caned 总线错误问题,错误显示控制器要发1,结果总线检测到0
  • ¥15 C#如何调用串口数据
  • ¥15 MATLAB与单片机串口通信
  • ¥15 L76k模块的GPS的使用
  • ¥15 请帮我看一看数电项目如何设计
  • ¥23 (标签-bug|关键词-密码错误加密)