如何使用正则表达式从该数组中提取书名和书价。
$bookList = array('PHP and MySQL Web Development (4th Edition)' => 49.95,
'Learning PHP, MySQL, and JavaScript' => 37.33,
'Beginning PHP and MySQL: From Novice to Professional' => 23.56,
'Head First PHP & MySQL' => 64.35);
正则表达式是提取函数的最佳方法吗?
function getBookName($bookList)
{
$bookRegEx = '';
$matchResult = array();
if (preg_match($bookRegEx, $bookList, $matchResult))
{
return intval($matchResult[0]);
}
else
{
return 0;
}
}