开发者

For loop of an array [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. 开发者_运维百科 Closed 12 years ago.

I want to make check of array by using for loop. The check is if selected value display it also display its index.


Not sure what you are asking but my guess would be a foreach loop

$array = array("hello" => "world");

foreach($array as $key => $value) {
  echo "This is my index " . $key . " with it's value " . $value;

}

//prints This is my index hello with it's value world


You can have index by $key using foreach will help you.

for($array as $key=>$value){
if($selectedvalue){
echo $key." ".$value ;

}


}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜