|
Posted by Steve on 04/16/07 20:09
| class object
| {
| var $lines ;
| var $posFound ;
|
| function object()
| {
| $lines = array( ... ) ;
| ...
| }
|
| function Search($val)
| {
| /* Line with error : */
| array_walk($this->lines, 'searchInLines', $val );
|
| /* solution : */
| array_walk($this->lines, array( $this,'searchInLines'), $val );
| }
|
| function searchInLines(&line, $id, $valueToSearch)
| {
| if ( $line[$id] == $valueToSearch )
| $this->posFound = $id ;
| }
| }
you are aware that &line in searchInLines needs to be &$line...AND that you
are treating it like the array itself when it is actually the VALUE of the
array at key $id...otherwise searchInLines will never set posFound (which
you should do when declaring it anyway).
:)
Navigation:
[Reply to this message]
|