I have two fields that are equal to each other, except for one field. Is there a way to get the comparison to ignore that field? It's an iterator pointer, the iterator position should not matter when comparing objects to each other.
Printable View
I have two fields that are equal to each other, except for one field. Is there a way to get the comparison to ignore that field? It's an iterator pointer, the iterator position should not matter when comparing objects to each other.
I'm sorry, can you be more specific? Some code to help us understand what you are doing?
Code:class foo {
private $_mapping = array(1,2,3);
private $_position = 0;
public function rewind() {
$this -> _position = 0;
}
public function current() {
return $this -> _mapping[$this -> _position];
}
public function key() {
return $this -> _position;
}
public function next() {
++$this -> _position;
}
public function valid() {
return isset($this -> _mapping[$this -> _position]);
}
}
$test = new foo();
$test2 = new foo()
foreach($test as $i){}
echo '' . $test == $test2; //false because _position is in different places, but the actual content in the same
I'm sorry but without any explanation, this still isn't helping. Let me try to explain what isn't exactly understandable...
Quote:
Originally Posted by ninja9578
- Two equal minus one results in none equal. So what exactly are you comparing?
- What do you mean by field? Are these <input> values passed to the server?
The mapping members are exactly the same, the _position item is different, but does not affect the "value" of the object publicly. I want the $test == $test2 to be true.
I want it be be the equivalent of this
Code:bool operator == (const foo & $bar){
return $bar -> _mapping == $this -> _mapping;
}