twittoris Posted September 15, 2010 Share Posted September 15, 2010 I am trying to assign the output getElementsBtTagName to an array. I am new to arrays and so far i have this: foreach ($rows as $row) { /*** get each column by tag name ***/ $cols = $row->getElementsByTagName('td'); //Declare array $address = array(); if($row->childNodes->length) { foreach($row->childNodes as $ii) { $address[$ii->nodeName] = $ii ->nodeValue; } } $adresses[] = $address; /*** echo the values ***/ echo $cols->item(0)->nodeValue.'<br />'; echo '<hr />'; echo $address; ; Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 16, 2010 Share Posted September 16, 2010 You're re-declaring address as a blank array each time the loop iterates. Maybe that's your problem. What is the output you are currently getting, and what is your expected output? Quote Link to comment Share on other sites More sharing options...
twittoris Posted September 16, 2010 Author Share Posted September 16, 2010 The output is a table with 6 rows. I am trying to assign each row to a variable. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 16, 2010 Share Posted September 16, 2010 Still a little hazy as to what you're exactly trying to achieve, I see you have another thread though... Is your code failing? Errors? Not creating correct output? What is your output? Perhaps this line is giving you an error due to the space? $address[$ii->nodeName] = $ii ->nodeValue; Quote Link to comment Share on other sites More sharing options...
twittoris Posted September 16, 2010 Author Share Posted September 16, 2010 yeah I have worked through all the other issues. This is my last one. I dont even know if its possible to put the output of a dom xpath into an array. I was hoping a veteran php-er would see what im trying to do and explain how to fix it if at all possible. Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted September 18, 2010 Share Posted September 18, 2010 yeah I have worked through all the other issues. This is my last one. I dont even know if its possible to put the output of a dom xpath into an array. I was hoping a veteran php-er would see what im trying to do and explain how to fix it if at all possible. Hire someone then. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.