【发布时间】:2010-10-22 20:00:41
【问题描述】:
所以我正在研究一个 Excel xml 解析类,并且我试图搜索文件头值的数组,以返回键整数。如果我可以得到键 int,那么我可以通过文件中标题的值来获取一整列。我尝试过使用 in_array、search_array 和一堆其他函数,但似乎没有任何效果。这是我正在使用的数组
array(30) { [0]=> array(1) { ["Data"]=> object(SimpleXMLElement)#37 (1) { [0]=> string(6) "Item #" } } [1]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#38 (0) { } } [2]=> array(1) { ["Data"]=> object(SimpleXMLElement)#39 (1) { [0]=> string(5) "Style" } } [3]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#40 (0) { } } [4]=> array(1) { ["Data"]=> object(SimpleXMLElement)#41 (1) { [0]=> string(5) "Brand" } } [5]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#42 (0) { } } [6]=> array(1) { ["Data"]=> object(SimpleXMLElement)#43 (1) { [0]=> string(5) "Color" } } [7]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#44 (0) { } } [8]=> array(1) { ["Data"]=> object(SimpleXMLElement)#45 (1) { [0]=> string(4) "Size" } } [9]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#46 (0) { } } [10]=> array(1) { ["Data"]=> object(SimpleXMLElement)#47 (1) { [0]=> string(12) "Active Price" } } [11]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#48 (0) { } } [12]=> array(1) { ["Data"]=> object(SimpleXMLElement)#49 (1) { [0]=> string(6) "Gender" } } [13]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#50 (0) { } } [14]=> array(1) { ["Data"]=> object(SimpleXMLElement)#51 (1) { [0]=> string(4) "Cost" } } [15]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#52 (0) { } } [16]=> array(1) { ["Data"]=> object(SimpleXMLElement)#53 (1) { [0]=> string(11) "On-hand Qty" } } [17]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#54 (0) { } } [18]=> array(1) { ["Data"]=> object(SimpleXMLElement)#55 (1) { [0]=> string(9) "Dept Name" } } [19]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#56 (0) { } } [20]=> array(1) { ["Data"]=> object(SimpleXMLElement)#57 (1) { [0]=> string(15) "Color Full Name" } } [21]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#58 (0) { } } [22]=> array(1) { ["Data"]=> object(SimpleXMLElement)#59 (1) { [0]=> string(8) "ItemType" } } [23]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#60 (0) { } } [24]=> array(1) { ["Data"]=> object(SimpleXMLElement)#61 (1) { [0]=> string(3) "UPC" } } [25]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#62 (0) { } } [26]=> array(1) { ["Data"]=> object(SimpleXMLElement)#63 (1) { [0]=> string(6) "UPCNEW" } } [27]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#64 (0) { } } [28]=> array(1) { ["Data"]=> object(SimpleXMLElement)#65 (1) { [0]=> string(3) "MPN" } } [29]=> array(1) { ["NamedCell"]=> object(SimpleXMLElement)#66 (0) { } } } array(1) { ["Data"]=> object(SimpleXMLElement)#37 (1) { [0]=> string(6) "Item #" } }
所以,基本上我只是想在该数组中搜索“品牌”,以返回与品牌相对应的数组键 (2)
【问题讨论】:
-
有什么理由不使用像 phpexcel 这样的现有库?
标签: php arrays multidimensional-array simplexml