Php返回值错误,不知道为什么


Php returns value wrong, any idea why?

在发布之前,我想说,我对PHP还很陌生。

它返回"值错误",这是我创建的回声:

$fields = array(  "amount"=>("5"),
                  "selected_customfields"=>("26656"),
                  "pageno"=>("0"),
                  "show_active_only"=>("1"),
                  "api_group"=>("//i removed this for here"),
                  "api_secret"=>("//i removed this for here"));
// Make the POST request using Curl
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);   
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
// Decode and display the output
$api_output =  curl_exec($ch);
$json_output = json_decode($api_output);
$output = $json_output?$json_output:$api_output;
// Clean up
curl_close($ch);
echo '<pre>';
var_dump($output);
echo '</pre>';

$output_filtered = array();
    foreach ($output as &$value) {
        echo '<pre>';
        $type = $value->cf_value_26656;
    if($type == "Opzet & webdevelopment (Eenmalig)") {
        var_dump($value);   
    } else {
        echo 'value wrong';
    }
    //var_dump();
        echo '</pre>';
        echo '==================================';
    }

cf_value_26656是对的,因为我对此还很陌生。有人可能很快就会发现错误。。

我在此将其更新为我拥有的更多代码,请原谅我之前没有上传它。

问候,

Kevin

由于var_dump输出

string(37)"Opzet&webdevelopment(Eenmalig)"

我们可以看到有4个缺失的字符(该字符串中有33个字符)。由于您在浏览器中进行调试,因此输出不是真正的输出。&实际上是&amp;,其呈现为&amp;说明了丢失的4个字符。因此,要么修改对实体的检查,要么将实体解码为其字符。

if($type == "Opzet &amp; webdevelopment (Eenmalig)") {

if(html_entity_decode($type) == "Opzet & webdevelopment (Eenmalig)") {