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; ; Link to comment https://forums.phpfreaks.com/topic/213527-array-help/ 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? Link to comment https://forums.phpfreaks.com/topic/213527-array-help/#findComment-1111503 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. Link to comment https://forums.phpfreaks.com/topic/213527-array-help/#findComment-1111506 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; Link to comment https://forums.phpfreaks.com/topic/213527-array-help/#findComment-1111509 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. Link to comment https://forums.phpfreaks.com/topic/213527-array-help/#findComment-1111528 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. Link to comment https://forums.phpfreaks.com/topic/213527-array-help/#findComment-1112385 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.