07-19-2010, 07:19 PM
|
#2 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
Normally I would tell you to global $engine and leave it at that, but I think we're only getting a chunk of code from the greater whole here; as suggested by $this I would presume that this is taken from a larger class that you are writing?
php Code:
public function cmp_ptl_friends ( $x ){ if ( in_array( $x[ 'user_id'], $this-> buddyList ) ).... $this-> leaderboardStats[ 'data'] = array_filter( $this-> leaderboardStats[ 'data'], array( $this, 'cmp_ptl_friends' ) );
The gist of the idea here is that function cmp_ptl_friends() should be a method of your class, and you can call it (other methods from the same class) from array_filter() using the syntax shown above.
Outside of that, if these were code snippets from a procedural script, your problem would have been the fact that cmp_ptl_friends() had no idea who or what $engine was. Since $engine was not created inside the function, nor was it passed as an argument, it doesn't yet exist in the scope of the function. You would have had to either pass it in as an argument or use the global keyword to bring it in from the global scope.
|
|
|
|