doulvyi2172 2015-01-24 17:54
浏览 71

从子数组的值相等的数组中删除元素

I have an array what consist of arrays. Have a looks into this file gist.
How you can see each array repeats two times. I need to delete the second, I need to compare them by 'key' value of array.
Thanks!

  • 写回答

2条回答 默认 最新

  • dongli2000 2015-01-24 18:05
    关注

    The undefined offset 6 error is telling you that there isnt an array element at position 6. Without seeing your error message and your code I cant tell you where the error is But you would need to see if the element exists using something like this:

    if (isset($array[index]))
    {
      //do something
    }
    

    This will handle the error, meaning you wont get the message, but you should see why the element doesnt exist, like Was there a problem when the arrays were made.

    Your error message will tell you which line the problem was on and therefore which array variables are causing these errors.

    UPDATE:

    your code will always return true as you are comparing a value to itself therefore it will be an empty array.

    $transll['key'] == $transll['key']
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度