I am trying to extract data from an XML file using simplexml. I am running a series of while and foreach loops to dig down to what I need.
However, I have found that after the elseif is finished I can no long display additional data to the screen (echo and print_r don't work). I have attached a code snippet for the elseif loop through the end of the end of the script. Please excuse the lousy code, I am a relatively new programmer.
elseif ($select_vars[1]==-1) {
$sub1=0;
$sub2=0;
$temp_count = 1;
$modnum=intval($select_vars[0]);
$sub1m = $xmls->module->{
intval($select_vars[0])}
->count();
while ($sub1 < $sub1m) {
foreach($xmls->module->{
$modnum}
->sublist1->{
$sub1}
as $hit2){
$sub2m = $xmls->module->{
$modnum}
->sublist1->{
$sub1}
->count();
while ($sub2 < $sub2m) {
foreach($xmls->module->{
$modnum}
->sublist1->{
$sub1}
->sublist2->{
$sub2}
as $hit3){
$template_string .= $temp_count . " - " . (string)$hit3 . "<br/>";
$temp_count = $temp_count+1;
$template_list[] = (string)$hit3;
}
$sub2 = $sub2+1;
}
$sub1 = $sub1+1;
$sub2 = 0;
}
}
echo "sub1 = " . $sub1 . "<br/>";
}
echo "here <br/><br/>".$template_string;
print_r ($template_list);
$template_list = array_unique($template_list);
sort($template_list);
print_r ($template_list);
I know the loops extract the right information because I can echo anywhere in the various loops except after the esleif closing bracket.
A live copy of the code is available at: http://www.aquilasolutions.us/software/templates/pages/filter-list.php
EDIT:
The output SHOULD be 3 selects and when the top box is filled when the others are empty a series of line (up to 400+) in the format ### - ####-####-####-#### should appear.
EDIT 2: To View the error: 1. set select "Module " to be anything 2. Set select sublist 1 and sublist 2 to be empty 3. Make sure the array at the top has 3 keys (it represents a session cookie called filter-list and represents the selected items)
EDIT 3: I have tracked down the error but not been able to resolve it.
There is a fatal error in my log (Fatal error: Call to a member function count() on null) on the line:
$sub2m = $xmls->module->{$modnum}->sublist1->{$sub1}->count();
I tried putting an isnull catch in but then there was a fatal error on the isnull....