Reputation: 153
To check if a field has or not a string i simply do:
if( $mindmap !== 'hello' ) {...
That is fine however the field has a "special" string, exactly the following:
$mindmap = "{"id":1}";
I tried:
if( $mindmap !== '{""};' ) {...
and
if( $mindmap !== '{"id":1}' ) {...
But that doesn't work and I don't know why to be honest, any idea?
Upvotes: 0
Views: 43
Reputation: 46900
Based on our discussion in comments it looks like that the input string sometimes has html entities in it. Here is a proof of concept that you can build upon, it decodes any possible entities within the string before comparing it with a standard one.
<?php
$mindmap = "{"id":1}";
var_dump( $mindmap === '{"id":1}'); //false
var_dump( html_entity_decode($mindmap) === '{"id":1}'); //true
Your if
would look like
if( html_entity_decode($mindmap) !== '{"id":1}')
Upvotes: 2
Reputation: 836
$mindmap = "{"id":1}";
echo "<pre>";
var_dump($mindmap !== "{"id":1}"); exit; //bool(false)
var_dump($mindmap === "{"id":1}"); exit; //bool(true)
Works perfectly...
what you need from that????
Upvotes: 0