1
我正在尋找一種方法(使用PHP)使用兩個不同的數組來獲取匹配項目的結果。陣列是體育統計數據。一個數組包含stats的定義,另一個數組是玩家的stat_id和stat值。每個數組中的匹配項目是stat_id。我正在尋找返回兩個數組中匹配項的結果。僅比較和返回數組中的匹配項目
第一個數組包含stat定義。這裏是統計定義數組的一個藥水......
[stat] => Array
(
[0] => SimpleXMLElement Object
(
[stat_id] => 4
[enabled] => 1
[name] => Passing Yards
[display_name] => Pass Yds
[sort_order] => 1
[position_type] => O
)
[1] => SimpleXMLElement Object
(
[stat_id] => 5
[enabled] => 1
[name] => Passing Touchdowns
[display_name] => Pass TD
[sort_order] => 1
[position_type] => O
)
[2] => SimpleXMLElement Object
(
[stat_id] => 6
[enabled] => 1
[name] => Interceptions
[display_name] => Int
[sort_order] => 0
[position_type] => O
)
[3] => SimpleXMLElement Object
(
[stat_id] => 9
[enabled] => 1
[name] => Rushing Yards
[display_name] => Rush Yds
[sort_order] => 1
[position_type] => O
)
[4] => SimpleXMLElement Object
(
[stat_id] => 10
[enabled] => 1
[name] => Rushing Touchdowns
[display_name] => Rush TD
[sort_order] => 1
[position_type] => O
)
[5] => SimpleXMLElement Object
(
[stat_id] => 12
[enabled] => 1
[name] => Reception Yards
[display_name] => Rec Yds
[sort_order] => 1
[position_type] => O
)
[6] => SimpleXMLElement Object
(
[stat_id] => 13
[enabled] => 1
[name] => Reception Touchdowns
[display_name] => Rec TD
[sort_order] => 1
[position_type] => O
)
[7] => SimpleXMLElement Object
(
[stat_id] => 15
[enabled] => 1
[name] => Return Touchdowns
[display_name] => Ret TD
[sort_order] => 1
[position_type] => O
)
[8] => SimpleXMLElement Object
(
[stat_id] => 16
[enabled] => 1
[name] => 2-Point Conversions
[display_name] => 2-PT
[sort_order] => 1
[position_type] => O
)
[9] => SimpleXMLElement Object
(
[stat_id] => 18
[enabled] => 1
[name] => Fumbles Lost
[display_name] => Fum Lost
[sort_order] => 0
[position_type] => O
)
[10] => SimpleXMLElement Object
(
[stat_id] => 57
[enabled] => 1
[name] => Offensive Fumble Return TD
[display_name] => Fum Ret TD
[sort_order] => 1
[position_type] => O
)
[11] => SimpleXMLElement Object
(
[stat_id] => 19
[enabled] => 1
[name] => Field Goals 0-19 Yards
[display_name] => FG 0-19
[sort_order] => 1
[position_type] => K
)
[12] => SimpleXMLElement Object
(
[stat_id] => 20
[enabled] => 1
[name] => Field Goals 20-29 Yards
[display_name] => FG 20-29
[sort_order] => 1
[position_type] => K
)
)
這裏是玩家的stat values數組。
[stat] => Array
(
[0] => SimpleXMLElement Object
(
[stat_id] => 4
[value] => 0
)
[1] => SimpleXMLElement Object
(
[stat_id] => 5
[value] => 0
)
[2] => SimpleXMLElement Object
(
[stat_id] => 6
[value] => 0
)
[3] => SimpleXMLElement Object
(
[stat_id] => 9
[value] => 0
)
[4] => SimpleXMLElement Object
(
[stat_id] => 10
[value] => 0
)
[5] => SimpleXMLElement Object
(
[stat_id] => 12
[value] => 0
)
[6] => SimpleXMLElement Object
(
[stat_id] => 13
[value] => 0
)
[7] => SimpleXMLElement Object
(
[stat_id] => 15
[value] => 0
)
[8] => SimpleXMLElement Object
(
[stat_id] => 16
[value] => 0
)
[9] => SimpleXMLElement Object
(
[stat_id] => 18
[value] => 0
)
[10] => SimpleXMLElement Object
(
[stat_id] => 57
[value] => 0
)
)