我需要从PHP数组中提取一个单独的字符串


I need to pull an individual string from a PHP array

我有一个数组,需要从中提取一段数据。我没有编写创建数组的原始代码,它的行为似乎不像我预期的那样,我的数组知识正在增长,但仍然相当新。这是阵列:

array(31) { ["title"]=> string(13) "Title of work" ["abstr"]=> string(163) "
Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum.
" ["outcomes"]=> string(163) "
Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum.
" ["CategorySelection"]=> string(11) "Application" ["research3"]=> string(0) "" ["research4"]=> string(0) "" ["research5"]=> string(0) "" ["research6"]=> string(0) "" ["innovation3"]=> string(0) "" ["innovation4"]=> string(0) "" ["innovation5"]=> string(0) "" ["innovation6"]=> string(0) "" ["application3"]=> string(308) "
The university has invited proposals from national food management services to potentially provide Miami with one or two directors to guide day-to-day management for university dining and to assist in refining and strengthening the strategic direction for our nationally recognized dining operation.
" ["application4"]=> string(308) "
The university has invited proposals from national food management services to potentially provide Miami with one or two directors to guide day-to-day management for university dining and to assist in refining and strengthening the strategic direction for our nationally recognized dining operation.
" ["application5"]=> string(308) "
The university has invited proposals from national food management services to potentially provide Miami with one or two directors to guide day-to-day management for university dining and to assist in refining and strengthening the strategic direction for our nationally recognized dining operation.
" ["application6"]=> string(308) "
The university has invited proposals from national food management services to potentially provide Miami with one or two directors to guide day-to-day management for university dining and to assist in refining and strengthening the strategic direction for our nationally recognized dining operation.
" ["integration3"]=> string(0) "" ["integration4"]=> string(0) "" ["integration5"]=> string(0) "" ["integration6"]=> string(0) "" ["references"]=> string(154) "Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. " ["organization"]=> string(154) "Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. " ["flipchart"]=> string(3) "yes" ["video"]=> string(3) "yes" ["comments"]=> string(154) "Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. " ["type"]=> string(11) "contributed" ["infocheck"]=> string(3) "Yes" ["presenters"]=> string(224) "[Doe, Jane undefined] middle_name = sldk department = sldkf institution = lksdj city = lsldkf state = lskdf country = slkdf office_phone = 123-456-7891 cell_phone = email_address = email@address.com website = " ["user_agent"]=> string(121) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36" ["keywords"]=> string(39) " Blackboard Civic Engagement Cognition " ["requested_format"]=> string(24) "Panel, 40-minute, Poster" }

我可以找出如何提取和回显标题等变量,甚至是顶级数组中的整个演示者数组,但我无法从演示者数组中提取电子邮件地址。如有任何帮助,我们将不胜感激。

数组的格式很奇怪,但我猜呈现者的值是一个带值的长字符串。

要获取电子邮件地址,请使用以下方法:

$strPresenters = $baseArray['presenters']; //actually I can't even track how to get to presenters, but you can figure that out with trial and error
preg_match('/email_address = ([^'s]*)/', $strPresenters, $aryMatch);
$strEmail = $aryMatch[1];

如果格式完全不同,您可能需要调整正则表达式。