• swoole_table测试



        public function test()
        {
            $count = [];
            $count[] = ['key' => 'name', 'type' => 'string', 'len' => 50];
            $count[] = ['key' => 'title', 'type' => 'string', 'len' => 50];

            $temp = new swoole_table(1024);
            $allType = ['int' => swoole_table::TYPE_INT, 'string' => swoole_table::TYPE_STRING, 'float' => swoole_table::TYPE_FLOAT];
            foreach ($count as $row) {
                $temp->column($row['key'], $allType[$row['type']], $row['len']);
            }
            $temp->create();

            foreach ([1, 2, 3] as $val) {
                $value = ['title' => "这是第{$val}个标题"];
                $temp->set($val, $value);
            }

            foreach ([4, 5, 6] as $val) {
                $value = ['name' => "这是第{$val}个名字"];
                $temp->set($val, $value);
            }

            foreach ([7, 8, 9] as $val) {
                $value = ['name' => "这是第{$val}个名字", 'title' => "这是第{$val}个标题"];
                $temp->set($val, $value);
            }

            $value = [];
            foreach ([1, 2, 3, 4, 5, 6, 7, 8, 9] as $val) {
                $value[] = $temp->get($val);
            }
            print_r($value);
        }

    美中不足的是还没找到可以遍历所有键值的方法。

  • 相关阅读:
    黑马程序员——指针的应用
    黑马程序员——C语言基础常量、运算符、函数
    黑马程序员——数组
    黑马程序员——循环结构for,while,do..while
    webView去掉右侧导航条
    使用Eclipse构建Maven的SpringMVC项目
    win7 自动登录
    eclipse 自动提示
    apache+php+mysql 环境配置
    KMP子串查找算法
  • 原文地址:https://www.cnblogs.com/fazo/p/5532647.html
Copyright © 2020-2023  润新知