Infinite loop in foreach on simplex

I am facing a specific problem as I did not find many links. I found the simpleXMLElement and foreach attributes that describe the same problem, but it has not responded for a year and has no answer.

For a little context, I'm trying to use PHPOffice/PHPExcel, and when downloading a file, xlsxthis frame cycle on simplexmlelementin lines 364 to 376 of Excel2007.php, available at https://github.com/PHPOffice/PHPExcel/blob/1.8/Classes/PHPExcel/Reader/Excel2007.php from which several lines are extracted here (I added var_dump and echo):

foreach ( $colourScheme as $k => $xmlColour ) {
    var_dump ( $xmlColour ); echo 'NEWVAR';
    $themePos = array_search ( $k, $themeOrderArray );
    if (! $themePos) {
        $themePos = $themeOrderAdditional ++;
    }
    if (isset ( $xmlColour->sysClr )) {
        $xmlColourData = $xmlColour->sysClr->attributes ();
        $themeColours [$themePos] = $xmlColourData ['lastClr'];
    } elseif (isset ( $xmlColour->srgbClr )) {
        $xmlColourData = $xmlColour->srgbClr->attributes ();
        $themeColours [$themePos] = $xmlColourData ['val'];
    }
}

$colourScheme var simplexmlelement, 12 SimpleXMLElements, thoses 12 simplexmlelement 0 , , "srgbClr".

, $k var 2 , ( 12 $colorScheme), , (, , , ).

php.ini ( 64- wampServer, Windows 7, eclisePDT -), .

; XDEBUG Extension

zend_extension = "D:/path/to/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11-x86_64.dll"
;
[xdebug]
xdebug.remote_enable = on
xdebug.remote_host = "localhost"
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = "D:/path/to/tmp/tmp"
xdebug.show_local_vars = on
xdebug.collect_params = on

EDIT: . , (php.ini ), eclipse . , , . (20 ), , , , , (750 ), . , , $k .

- -, , !

!

+4
1

, . , , - SimpleXML, : https://bugs.php.net/bug.php?id=55098 p >

, , , , - :

foreach ($colourScheme as $k => $xmlColour) {
   ...
}

children():

foreach ($colourScheme->children() as $k => $xmlColour) {
   ...
}

, , - , :

if ($colourScheme->count() > 0) {
   ...
}

, SimpleXML , . children(), , , , foreach, , SimpleXML , . , ( ):

enter image description here

, :

$xml = simplexml_load_string($xmlstring);
$json = json_encode($xml);
$array = json_decode($json,TRUE);

:

http://php.net/manual/en/simplexmlelement.children.php http://php.net/manual/en/simplexmlelement.count.php

+2

Source: https://habr.com/ru/post/1617255/


All Articles