循环遍历数组并使用if语句更改值

时间:2015-10-19 12:25:03

标签: php

我有DB的以下数据数组,如果符合条件,我想将STATUS值更改为字符串

Array ( [0] => stdClass Object ( [ORDER] => 1321[DATE] => 2015-10-05 [TEXT] => TESTING [OTIME] => 06:03:03 [STATUS] => 3 [CODE] => ABC) [1] => stdClass Object ([ORDER] => 1321[DATE] => 2015-10-05 [TEXT] => TESTING [OTIME] => 06:03:03 [STATUS] => 3 [CODE] => ABC ) ) 

我想循环访问数据并执行以下操作:

if (STATUS=3) {
        STATUS ="replace the number with some text";
    }

1 个答案:

答案 0 :(得分:1)

假设您的输出存储在$ results数组中,所以现在您可以迭代循环并检查如下:

new*Schedule*