tags:

views:

50

answers:

2

Hello! I have an object which gets a String. I want to compare it with a String and I don't know how to do it. My source is something like it:

$field = $this->form->getFieldset('profile');
$website = "Web site";

if ($field->label == $website){
   echo "good";
}else{
   echo "bad";
}
+1  A: 

Don't really understand the problem but you could convert it to an array using get_object_vars.

This is assuming that $field->label is actually a property rather than an object?

$field = $this->form->getFieldset('profile');
$website = "Web site";
$array = get_object_vars($field);

if ($array['label'] == $website) {
    echo 'Hoorah!';
}
Stoosh
A: 

if the result of gettype($field->label) is an object, you have to implement the magic method __toString()

stillstanding