我在格式鍵的字符串的一些數據:值鍵:值鍵:值等..PHP正則表達式匹配的煩惱
我試圖把它變成使用正則表達式匹配的數組。所有的鍵都是大寫字母,後面跟着一個冒號。然後有一個空間,價值開始。然後是空格,然後是下一個鍵。該值可以包含大寫/小寫字母,數字,空格,逗號或等號。
例如,我想該輸入字符串:
NAME: Name of Item COLOR: green SIZE: 40
化作此數組:
newArray[NAME] = Name of Item
newArray[COLOR] = green
newArray[SIZE] = 40
任何幫助十分讚賞。此外,我無法訪問輸入的格式,或者我會讓自己更容易。
如果其中一個答案解決以下通過點擊您的問題,請接受它答案旁邊的勾號 – ghostJago