I need to use a php-variable in a if-statement. The variable is defined with html-code that contains an id from a script.
$variable = "<label id='new_value'></label>";
If i call this variable, the result is always a number. Now I want to compare this variable in a if-statement with a normal number to call some other code. For example:
if($variable == 5){some code}
The problem is that my variable isn't a real number so I can't compare the html-element with a number like 5 in the if-statement, even if the variable would display the same number (5) when it's called on a website.
Is it possible to set the type from the variable as integer to compare it with another number in the if-statement or to define a new variable which extracts the content from the other variable and can be used as integer?
I hope someone can help me :-)
Aucun commentaire:
Enregistrer un commentaire