dth8312 2014-03-26 11:10
浏览 5
已采纳

带有不同数字的未定义偏移量

I am trying to explode some links, but some of them contain 7 / and some of them have 6 / Therefor I get error Notice: Undefined Offset 7, how can I overcome this:

$imagethumb = array('6 slashes in url','7 slashes'); // this is just for simulating
$imagethumbs = explode('/', $imagethumb);
$thumbname = $imagethumbs[7];
  • 写回答

2条回答 默认 最新

  • douyue7536 2014-03-26 11:12
    关注

    Always choose the latest entry in the array.

    You can count the amount of indexes using the count() function.

    You code should look like this: $thumbname = $imagethumbs[count($imagethumbs) - 1];

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

报告相同问题?

悬赏问题

  • ¥15 请教 这种post请求参数,该如何填写??
  • ¥15 找代写python里的jango设计在线书店
  • ¥15 请教如何关于Msg文件解析
  • ¥200 sqlite3数据库设置用户名和密码
  • ¥15 AutoDL无法使用docker install吗?
  • ¥15 cups交叉编译后移植到tina sdk的t113,只需要实现usb驱动打印机,打印pdf文件
  • ¥30 关于#wireshark#的问题:需要网络应用流量数据集需要做长度序列的实验,需要与应用产生的会话的数据包的长度,如视频类或者聊天类软件
  • ¥15 根据上述描述表示泥浆密度沿着管路的长度方向在不断变化,如何来表示泥浆密度随管路的变化(标签-matlab|关键词-流计算)
  • ¥21 matlab可以把图像数据转换为小波分析吗
  • ¥60 基于香农编码的图像压缩算法实现