On Dec 17, 2010, at 05:15, ojonam wrote:

> $getLink = function($x){return $this->Html->link($x, '#'.$x);};
> $alphabet = array_map($getLink, array_merge(range('a','z')));

In PHP 6.x or possibly 5.4.x you should be able to do this:

$getLink = function($x)use($this){return $this->Html->link($x, '#'.$x);};
$alphabet = array_map($getLink, array_merge(range('a','z')));

However, it's not possible for an anonymous function to use "$this" in PHP 
5.3.x; see this bug report:

http://bugs.php.net/bug.php?id=49543

Until then, you have to copy $this to a temporary variable; here, I copy it to 
"$view":

$view = $this;
$getLink = function($x)use($view){return $view->Html->link($x, '#'.$x);};
$alphabet = array_map($getLink, array_merge(range('a','z')));



Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to