Isset()在应为true时返回false-Symfony PHP

Isset()在应为true时返回false-Symfony PHP,php,symfony,if-statement,isset,Php,Symfony,If Statement,Isset,我是一名新开发人员,在一家公司的网站上工作。我使用isset()检查变量中是否设置了某个值,但它总是返回false。代码如下: $prices_with_source = $user_company->getBranchApiImplementation()->getApiClass($controller,$apiDisabled)->getProductPrices($em, $partnership, array( array('product' => $produ

我是一名新开发人员,在一家公司的网站上工作。我使用isset()检查变量中是否设置了某个值,但它总是返回false。代码如下:

$prices_with_source = $user_company->getBranchApiImplementation()->getApiClass($controller,$apiDisabled)->getProductPrices($em, $partnership, array( array('product' => $product , 'quantity' => 1) ));
$prices_with_source = is_array($prices_with_source) ? reset($prices_with_source) : $prices_with_source;

if(isset($prices_with_source['discountedPrice']) && $prices_with_source['discountedPrice'] > 0) {
    $price = $prices_with_source['discountedPrice'];
}

if(isset($prices_with_source['suggestedPrice'])) {
    $price = $prices_with_source['suggestedPrice'];
}
它应该输入if语句,因为我知道$price_with_sources有值。我不知道为什么它不起作用。我使用var_dump在if语句之前使用_源检查$prices_的值,这是输出:

array(1) {
    [1]=> array(3) {
        ["discountedPrice"]=> string(4) "5.99"
        ["suggestedPrice"]=> string(4) "5.99"
        ["source"]=> int(0)
    }
}
如果任何人有任何有用的信息,将不胜感激,谢谢

更新的if块:

if(isset($prices_with_source[1]['discountedPrice']) && $prices_with_source[1]['discountedPrice'] > 0) {
    $price = $prices_with_source[1]['discountedPrice'];
}

if(isset($prices_with_source[1]['suggestedPrice'])) {
    $price = $prices_with_source[1]['suggestedPrice'];
}

isset($prices\u和\u来源[1]['discountedPrice'])
。。。。它是一个嵌套数组。您在那里有一个嵌套数组。索引不是
“折扣价格”
您可以始终使用
$row=current($prices\u with\u source)如果您知道您在列表中只有一个项目collection@Torchify,有两个if条件。谢谢,这解决了问题。我现在明白错误是什么了!