<?php

/**
 * Created by PhpStorm.
 * User: stanley-king
 * Date: 2017/5/19
 * Time: 下午2:00
 */
class TestRegex extends PHPUnit_Framework_TestCase
{
    public function testReserved()
    {
        $t = base64_encode('5');
        $regxp = '/([^=#]+=[^#]*)[#]?/i';

        $src='top=1#stars=3#desc=你好世界';
        $val = preg_match_all($regxp,$src,$match);
        if($val == false) return false;

        $result = [];
        if(count($match) == 2)
        {
            foreach($match[1] as $val)
            {
                $kv = preg_split('/=/',$val);
                if(!empty($kv))
                {
                    $k = trim($kv[0]);
                    $v = trim($kv[1]);
                    if(!empty($k)) {
                        $result[$k] = $v;
                    }
                }
            }
        }

    }
}
