我現在有以下代碼:PHP關聯陣列,正則表達式,陣列
$content = "
<name>Manufacturer</name><value>John Deere</value><name>Year</name><value>2001</value><name>Location</name><value>NSW</value><name>Hours</name><value>6320</value>";
我需要找到創造的方法和陣列name=>value
。例如,Manufacturer => John Deere
。
誰能幫我用一個簡單的代碼剪斷我嘗試了一些正則表達式,但甚至不工作,提取你不想使用正則表達式這個名稱或值,例如:
$pattern = "/<name>Manufacturer<\/name><value>(.*)<\/value>/";
preg_match_all($pattern, $content, $matches);
$st_selval = $matches[1][0];
快速簡單:)非常感謝! – Michael 2010-08-18 17:28:00