如何使用PHP计算数组值在另一个数组元素中重复的次数?

如何使用PHP计算数组值在另一个数组元素中重复的次数?,php,xml,Php,Xml,我有一段XML数据,如下所示: <scientist> <name>Emmy Noether&amp;Amalie</name> </scientist> <day> <date>03-23-2015</date> <wiki>Emmy Noether&amp;Amalie was an influential German mathematician known for

我有一段XML数据,如下所示:

<scientist>
  <name>Emmy Noether&amp;Amalie</name>
</scientist>

<day>
  <date>03-23-2015</date>
  <wiki>Emmy Noether&amp;Amalie was an influential German mathematician known for her groundbreaking contributions to abstract algebra and theoretical physics. Emmy Noether&amp;Amalie was born on 23 March 1882, the first of four children. In 1932 Emmy Noether and Emil Artin received the Ackermann–Teubner Memorial Award for their contributions to mathematics.</wiki>
</day>

艾美·诺瑟;阿玛莉
03-23-2015
艾美·诺瑟;阿玛莉是一位有影响力的德国数学家,以其对抽象代数和理论物理的开创性贡献而闻名。艾美·诺瑟;阿玛莉于1882年3月23日出生,是四个孩子中的第一个。1932年,艾美·诺瑟和艾米尔·阿廷因对数学的贡献而获得阿克曼-特布纳纪念奖。

我的问题是如何计算在上述XML元素的
wiki
元素中重复
科学家的
姓名
值(即
艾美·诺瑟和阿玛莉
)的次数?谢谢您的帮助。

您是否正在使用SimpleXML解析XML


如果隔离了所有wiki标记,则可以使用substr_count函数计算名称标记出现的次数

yes确切地说,类似于
file='file.xml'$xml=文件获取内容($file)$xml=新的simplexmlement($xml)$array=json_decode(json_encode($xml),TRUE)