Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3287964
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:33:12+00:00 2026-05-17T20:33:12+00:00

So Im working on a Excel xml parsing class, and Im trying to search

  • 0

So Im working on a Excel xml parsing class, and Im trying to search through an array of the header values of the file, to return the key integer. If I can get the key int, then I can grab an entire column by the value of the header in the file. I have tried using in_array, search_array and a bunch of other functions, but nothing is seeming to work. Here is the array Im working with

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 #" } } 

So ya basically I am just trying to for instance search for “Brand” within that array, to return the array key that corrosponds to brand (2)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:33:12+00:00Added an answer on May 17, 2026 at 8:33 pm

    It’s hard to answer your question without seeing what you used to generate the var_dump output above.

    My best guess is that that data itself looks something like this:

    $data = array(array("Data" => simplexml_load_string("<Tag>Brand</Tag>")));
    

    If that’s the case, you can return the value “Brand” by calling $data[0]["Data"]

    You could iterate over the array searching for the term “Brand” by doing this:

    $rowNum = 0;
    $cellNum = 0;
    foreach($data as $row){
        $rowNum++;
        foreach($row as $cellKey => $cellVal){
            $cellNum++;
            echo "Row $rowNum at cell $cellNum has key '$cellKey' and val '$cellVal'";
        }    
    }
    

    This will output:

    Row 1 at cell 1 has key 'Data' and val 'Brand'
    

    With that said, Gordon is probably correct, and an existing library, such as phpexcel is probably a way less painful way to do this type of thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on Open XML document format for excel sheets. var nodeList = WorksheetXml.SelectNodes(@//c[child::f]);
I have generated an XSD file for an XML file and it's working when
Working with Excel interop, I'm trying be very careful about not implicitly creating any
I've been trying to get this Excel function working correctly, and I've hit a
I have an working Excel file, with file I can send data extracted from
reading excel files from C# working well in 32 bit version server. It is
I'm working on an import (from Excel) dialog to select ranges of cells. When
I am currently working on a project to convert a number of Excel VBA
I'm working with a MySQL database that has some data imported from Excel .
I'm working on some code that generates an Excel spreadsheet server-side and then downloads

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.