English 中文(简体)
队列密钥比较失败
原标题:Array key comparison fails
  • 时间:2012-05-21 21:51:11
  •  标签:
  • php
  • loops

由于某种原因,当我通过一个数组使用每个圆环来进行循环时,一个条件无法将键与字符串进行比较。我的数组有两个索引,第一个是整数,第二个是字符串。

$firmas[] = $credito[ acreditado ];
$firmas[ cbi ] = "LIC. MARCELA SOTO ALARCÓN";

当循环发现那个时刻的钥匙是字符串之一时,我想做点其他事情,但出于某种原因,当我评价整数指数时,结果是真实的。

 foreach($firmas as $key => $firma){
            var_dump($key);
            var_dump($key== cbi );die();
        }

产出为

int(0) bool(true) 

但如你所见 条件正在寻找字符串 cbi, 因此结果应该与整数索引不符, 并且对字符串来说是真实的 。

这是怎么回事?

最佳回答

在 PHP 中, 所有字符串都等于 0 , 虽然不等于它。 请尝试使用 , 而不是仅仅

增编:所有不以数字开始的字符串<它们>都等于 0

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签