我的數據 -的preg_match - 正則表達式來創建陣列
{'/Users/aaron/Applications/developer-vagrant/web/g.php': {'total': 22}}
{'/Users/aaron/.vim/autoload/timetap.vim': {'total': 0}}
{'/Users/aaron/.vimrc': {'total': 5}}
{'/Users/aaron/Documents/Programming/PHP/TimeTapCLI/composer.json': {'total': 144}}
{'/Users/aaron/Documents/Programming/PHP/TimeTapCLI/timetap.php': {'total': 351}}
{'/Users/aaron/Box/linux/.vim/autoload/timetap.vim': {'total': 37}}
{'/Users/aaron/Box/cats.tex': {'total': 184}}
我試圖創建一個正則表達式,所以我可以在上面轉換成使用的preg_match數組。我想要的數據看起來像 -
我想所有的數據數組所以我相信它應該看起來像如下─
array (
[0] => array (
[0] => '/Users/aaron/Box/cats.tex'
[1] => array (
[total] =>'184'
)
}
}
我的企圖的preg_match -
$subject = file_get_contents('/Users/aaron/.timetap/full.db');
$pattern = '{...}';
preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE);
什麼該模式是爲了採取上述數據並將其轉換爲PHP中的數組?有沒有PHP函數可以將其轉換爲數組而不使用preg_match?
我正則表達式是完全罰款 - 兄弟。無論如何,由於意思 - 您的輸出不符合要求。 – Falt4rm
What @ Falt4rm ?!我沒有提到你的正則表達式/答案。當我回答時,你的回答並沒有建立一個數組。 – chris85
哦,哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈那麼Mb。我爲此道歉。 – Falt4rm