小编xyx*_*yxy的帖子

为什么我们应该最小化中断的使用并继续循环?

当我是一名新生时,我们的教练允许我们使用breakcontinue循环使用.我当时大部分时间都做过,因为它终止/继续循环.现在我在大二的时候,我的导师告诉我,使用break/ continue是不可取的.你能告诉我为什么吗?什么影响休息/继续的方式?

c c++

5
推荐指数
3
解决办法
2740
查看次数

在php中获取数组的索引

我有一个包含以下内容的数组:

$code_ids
 [138]=>
  string(0) "asdsad"
  [126]=>
  string(0) ""
  [163]=>
  string(0) "asdasd"
  [162]=>
  string(0) ""
  [135]=>
  string(0) "awawawaw"
  [59]=>
  string(0) ""
  [63]=>
  string(0) ""
  [70]=>
  string(0) ""
  [146]=>
  string(0) ""
  [155]=>
  string(0) ""
  [66]=>
  string(0) ""
Run Code Online (Sandbox Code Playgroud)

如果它包含任何内容,我希望得到所有索引.你怎么做到这一点?我试过了

foreach($code_ids as $code_id) {
  if(!empty($code_id)) {
     $index[] = $code_id;
  }
}
Run Code Online (Sandbox Code Playgroud)

这个问题是它得到了它的价值.我只想要索引.

php foreach key

1
推荐指数
1
解决办法
57
查看次数

标签 统计

c ×1

c++ ×1

foreach ×1

key ×1

php ×1