小编Nee*_*ion的帖子

将具有匿名函数的代码转换为PHP 5.2

我有一些PHP 5.3代码,它构建一个要传递给视图的数组.这是我的代码.

# Select all this users links.
$data = $this->link_model->select_user_id($this->user->id);
if (count($data) > 0) {
    # Process the data into the table format.
    $table = array
    (
        'properties' => array
        (
            'delete_link_column' => 0,
        ),
        'callbacks' => array
        (
            # Callback for the name link.
            function($value) {
                return sprintf('<a href="/links/view/name/%s">%s</a>', $value, $value);
            },
            # Callback for the category link.
            function($value) {
                return sprintf('<a href="/category/view/name/%s">%s</a>', $value, $value);
            },
            # Callback for the creation date.
            function($value) {
                return date('jS M Y', …
Run Code Online (Sandbox Code Playgroud)

php anonymous-function

11
推荐指数
2
解决办法
5612
查看次数

标签 统计

anonymous-function ×1

php ×1