3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $xml = '<?xml version="1.0" encoding="UTF-8"?> <translations> <translation id="title"> <english name="name1" ad="ad1">Hello there, how are you?</english> <italian name="name2" ad="ad2">Ciao, come stai?</italian> </translation> <translation id="text2"> <english name="name3" ad="ad4">222Hello there, how are you?</english> <italian name="name3" ad="ad4">222Ciao, come stai?</italian> </translation> <translation id="text3"> <english name="name5" ad="ad5">333Hello there, how are you?</english> <italian name="name6" ad="ad6">333Ciao, come stai?</italian> </translation> </translations>'; $xml = new SimpleXMLElement($xml); //var_dump($xml->translation); //echo $xml->translations->translation->english['ad']; //echo $xml->translations->translation->italian['name']; foreach ($xml->translation as $element) { foreach($element as $key => $val) { echo $element['id']."{$key}: {$val}".PHP_EOL; } } $xml = simplexml_load_string($xml); $json = json_encode($xml); $array = json_decode($json,TRUE); var_dump($array);
based on N47kZ
Output for 5.2.1 - 7.1.0
titleenglish: Hello there, how are you? titleitalian: Ciao, come stai? text2english: 222Hello there, how are you? text2italian: 222Ciao, come stai? text3english: 333Hello there, how are you? text3italian: 333Ciao, come stai? Warning: simplexml_load_string(): Entity: line 5: parser error : Start tag expected, '<' not found in /in/deXvE on line 33 Warning: simplexml_load_string(): in /in/deXvE on line 33 Warning: simplexml_load_string(): ^ in /in/deXvE on line 33 bool(false)
Output for 5.2.0
titleenglish: Hello there, how are you? titleitalian: Ciao, come stai? text2english: 222Hello there, how are you? text2italian: 222Ciao, come stai? text3english: 333Hello there, how are you? text3italian: 333Ciao, come stai? Warning: simplexml_load_string(): Entity: line 5: parser error : Start tag expected, '<' not found in /in/deXvE on line 33 Warning: simplexml_load_string(): in /in/deXvE on line 33 Warning: simplexml_load_string(): ^ in /in/deXvE on line 33 NULL
Output for 5.1.0 - 5.1.6
titleenglish: Hello there, how are you? titleitalian: Ciao, come stai? text2english: 222Hello there, how are you? text2italian: 222Ciao, come stai? text3english: 333Hello there, how are you? text3italian: 333Ciao, come stai? Warning: simplexml_load_string(): Entity: line 5: parser error : Start tag expected, '<' not found in /in/deXvE on line 33 Warning: simplexml_load_string(): in /in/deXvE on line 33 Warning: simplexml_load_string(): ^ in /in/deXvE on line 33 Fatal error: Call to undefined function json_encode() in /in/deXvE on line 34
Process exited with code 255.
Output for 5.0.2 - 5.0.5
titleenglish: Hello there, how are you? titleitalian: Ciao, come stai? text2english: 222Hello there, how are you? text2italian: 222Ciao, come stai? text3english: 333Hello there, how are you? text3italian: 333Ciao, come stai? Warning: Entity: line 5: parser error : Start tag expected, '<' not found in /in/deXvE on line 33 Warning: in /in/deXvE on line 33 Warning: ^ in /in/deXvE on line 33 Fatal error: Call to undefined function json_encode() in /in/deXvE on line 34
Process exited with code 255.
Output for 5.0.1
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 titleenglish: Hello there, how are you?PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 titleitalian: Ciao, come stai?PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 text2english: 222Hello there, how are you?PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 text2italian: 222Ciao, come stai?PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 text3english: 333Hello there, how are you?PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 text3italian: 333Ciao, come stai?PHP_EOL Warning: Entity: line 5: parser error : Start tag expected, '<' not found in /in/deXvE on line 33 Warning: in /in/deXvE on line 33 Warning: ^ in /in/deXvE on line 33 Fatal error: Call to undefined function json_encode() in /in/deXvE on line 34 *** Error in `/bin/php-5.0.1': double free or corruption (fasttop): 0x0000000000d727a0 *** ======= Backtrace: ========= /usr/lib/libc.so.6(+0x6f364)[0x7f8c308a0364] /usr/lib/libc.so.6(+0x74d96)[0x7f8c308a5d96] /usr/lib/libc.so.6(+0x7557e)[0x7f8c308a657e] /bin/php-5.0.1(shutdown_memory_manager+0x5f)[0x5b6acf] /bin/php-5.0.1(php_request_shutdown+0x1df)[0x5945df] /bin/php-5.0.1(main+0x584)[0x43fe54] /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f8c30851710] /bin/php-5.0.1[0x44088d] ======= Memory map: ======== 00400000-007cc000 r-xp 00000000 00:00 0 007cc000-009cb000 ---p 00000000 00:00 0 009cb000-009fa000 rwxp 00000000 00:00 0 00a00000-00a01000 rwxp 00000000 00:00 0 00c7e000-00d91000 rwxp 00000000 00:00 0 [heap] 7f8c2bdea000-7f8c2be00000 r-xp 00000000 00:13 7782 /usr/lib/libgcc_s.so.1 7f8c2be00000-7f8c2bfff000 ---p 00016000 00:13 7782 /usr/lib/libgcc_s.so.1 7f8c2bfff000-7f8c2c000000 rwxp 00015000 00:13 7782 /usr/lib/libgcc_s.so.1 7f8c2c000000-7f8c2c021000 rwxp 00000000 00:00 0 7f8c2c021000-7f8c30000000 ---p 00000000 00:00 0 7f8c301d7000-7f8c301e2000 r-xp 00000000 00:13 7901 /usr/lib/libnss_files-2.23.so 7f8c301e2000-7f8c303e1000 ---p 0000b000 00:13 7901 /usr/lib/libnss_files-2.23.so 7f8c303e1000-7f8c303e2000 r-xp 0000a000 00:13 7901 /usr/lib/libnss_files-2.23.so 7f8c303e2000-7f8c303e3000 rwxp 0000b000 00:13 7901 /usr/lib/libnss_files-2.23.so 7f8c303e3000-7f8c303ed000 rwxp 00000000 00:00 0 7f8c303ed000-7f8c30405000 r-xp 00000000 00:13 7927 /usr/lib/libpthread-2.23.so 7f8c30405000-7f8c30604000 ---p 00018000 00:13 7927 /usr/lib/libpthread-2.23.so 7f8c30604000-7f8c30605000 r-xp 00017000 00:13 7927 /usr/lib/libpthread-2.23.so 7f8c30605000-7f8c30606000 rwxp 00018000 00:13 7927 /usr/lib/libpthread-2.23.so 7f8c30606000-7f8c3060a000 rwxp 00000000 00:00 0 7f8c3060a000-7f8c3062f000 r-xp 00000000 00:13 7870 /usr/lib/liblzma.so.5.2.2 7f8c3062f000-7f8c3082e000 ---p 00025000 00:13 7870 /usr/lib/liblzma.so.5.2.2 7f8c3082e000-7f8c3082f000 r-xp 00024000 00:13 7870 /usr/lib/liblzma.so.5.2.2 7f8c3082f000-7f8c30830000 rwxp 00025000 00:13 7870 /usr/lib/liblzma.so.5.2.2 7f8c30830000-7f8c30831000 rwxp 00000000 00:00 0 7f8c30831000-7f8c309c9000 r-xp 00000000 00:13 7737 /usr/lib/libc-2.23.so 7f8c309c9000-7f8c30bc8000 ---p 00198000 00:13 7737 /usr/lib/libc-2.23.so 7f8c30bc8000-7f8c30bcc000 r-xp 00197000 00:13 7737 /usr/lib/libc-2.23.so 7f8c30bcc000-7f8c30bce000 rwxp 0019b000 00:13 7737 /usr/lib/libc-2.23.so 7f8c30bce000-7f8c30bd2000 rwxp 00000000 00:00 0 7f8c30bd2000-7f8c30d30000 r-xp 00000000 00:13 8004 /usr/lib/libxml2.so.2.9.3 7f8c30d30000-7f8c30f2f000 ---p 0015e000 00:13 8004 /usr/lib/libxml2.so.2.9.3 7f8c30f2f000-7f8c30f37000 r-xp 0015d000 00:13 8004 /usr/lib/libxml2.so.2.9.3 7f8c30f37000-7f8c30f39000 rwxp 00165000 00:13 8004 /usr/lib/libxml2.so.2.9.3 7f8c30f39000-7f8c30f3a000 rwxp 00000000 00:00 0 7f8c30f3a000-7f8c30f4f000 r-xp 00000000 00:13 7896 /usr/lib/libnsl-2.23.so 7f8c30f4f000-7f8c3114e000 ---p 00015000 00:13 7896 /usr/lib/libnsl-2.23.so 7f8c3114e000-7f8c3114f000 r-xp 00014000 00:13 7896 /usr/lib/libnsl-2.23.so 7f8c3114f000-7f8c31150000 rwxp 00015000 00:13 7896 /usr/lib/libnsl-2.23.so 7f8c31150000-7f8c31153000 rwxp 00000000 00:00 0 7f8c31153000-7f8c31155000 r-xp 00000000 00:13 7755 /usr/lib/libdl-2.23.so 7f8c31155000-7f8c31355000 ---p 00002000 00:13 7755 /usr/lib/libdl-2.23.so 7f8c31355000-7f8c31356000 r-xp 00002000 00:13 7755 /usr/lib/libdl-2.23.so 7f8c31356000-7f8c31357000 rwxp 00003000 00:13 7755 /usr/lib/libdl-2.23.so 7f8c31357000-7f8c3145a000 r-xp 00000000 00:13 7872 /usr/lib/libm-2.23.so 7f8c3145a000-7f8c3165a000 ---p 00103000 00:13 7872 /usr/lib/libm-2.23.so 7f8c3165a000-7f8c3165b000 r-xp 00103000 00:13 7872 /usr/lib/libm-2.23.so 7f8c3165b000-7f8c3165c000 rwxp 00104000 00:13 7872 /usr/lib/libm-2.23.so 7f8c3165c000-7f8c31670000 r-xp 00000000 00:13 7934 /usr/lib/libresolv-2.23.so 7f8c31670000-7f8c3186f000 ---p 00014000 00:13 7934 /usr/lib/libresolv-2.23.so 7f8c3186f000-7f8c31870000 r-xp 00013000 00:13 7934 /usr/lib/libresolv-2.23.so 7f8c31870000-7f8c31871000 rwxp 00014000 00:13 7934 /usr/lib/libresolv-2.23.so 7f8c31871000-7f8c31874000 rwxp 00000000 00:00 0 7f8c31874000-7f8c31889000 r-xp 00000000 00:13 8008 /usr/lib/libz.so.1.2.8 7f8c31889000-7f8c31a88000 ---p 00015000 00:13 8008 /usr/lib/libz.so.1.2.8 7f8c31a88000-7f8c31a89000 r-xp 00014000 00:13 8008 /usr/lib/libz.so.1.2.8 7f8c31a89000-7f8c31a8a000 rwxp 00015000 00:13 8008 /usr/lib/libz.so.1.2.8 7f8c31a8a000-7f8c31a92000 r-xp 00000000 00:13 7747 /usr/lib/libcrypt-2.23.so 7f8c31a92000-7f8c31c91000 ---p 00008000 00:13 7747 /usr/lib/libcrypt-2.23.so 7f8c31c91000-7f8c31c92000 r-xp 00007000 00:13 7747 /usr/lib/libcrypt-2.23.so 7f8c31c92000-7f8c31c93000 rwxp 00008000 00:13 7747 /usr/lib/libcrypt-2.23.so 7f8c31c93000-7f8c31cc1000 rwxp 00000000 00:00 0 7f8c31ccd000-7f8c31cce000 rwxp 00000000 00:00 0 7f8c31cce000-7f8c31ccf000 r-xp 00000000 00:13 1726160 /usr/bin/daemon-preload.so 7f8c31ccf000-7f8c31ece000 ---p 00001000 00:13 1726160 /usr/bin/daemon-preload.so 7f8c31ece000-7f8c31ecf000 rwxp 00000000 00:13 1726160 /usr/bin/daemon-preload.so 7f8c31ecf000-7f8c31ed0000 rwxp 00000000 00:00 0 7f8c31ed0000-7f8c31ef3000 r-xp 00000000 00:13 7564 /usr/lib/ld-2.23.so 7f8c31ef3000-7f8c320f3000 ---p 00000000 00:00 0 7f8c320f3000-7f8c320f4000 r-xp 00023000 00:13 7564 /usr/lib/ld-2.23.so 7f8c320f4000-7f8c320f5000 rwxp 00024000 00:13 7564 /usr/lib/ld-2.23.so 7f8c320f5000-7f8c320f6000 rwxp 00000000 00:00 0 7ffcce482000-7ffcce4a3000 rwxp 00000000 00:00 0 [stack] 7ffcce4e1000-7ffcce4e4000 r--p 00000000 00:00 0 [vvar] 7ffcce4e4000-7ffcce4e6000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Process exited with code 134.
Output for 5.0.0
Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 titleenglish: Hello there, how are you?PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 titleitalian: Ciao, come stai?PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 text2english: 222Hello there, how are you?PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 text2italian: 222Ciao, come stai?PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 text3english: 333Hello there, how are you?PHP_EOL Notice: Use of undefined constant PHP_EOL - assumed 'PHP_EOL' in /in/deXvE on line 29 text3italian: 333Ciao, come stai?PHP_EOL Warning: Entity: line 5: parser error : Start tag expected, '<' not found in /in/deXvE on line 33 Warning: in /in/deXvE on line 33 Warning: ^ in /in/deXvE on line 33 Fatal error: Call to undefined function json_encode() in /in/deXvE on line 34 *** Error in `/bin/php-5.0.0': free(): invalid next size (fast): 0x00000000012d54b0 *** ======= Backtrace: ========= /usr/lib/libc.so.6(+0x6f364)[0x7f637cfa2364] /usr/lib/libc.so.6(+0x74d96)[0x7f637cfa7d96] /usr/lib/libc.so.6(+0x7557e)[0x7f637cfa857e] /bin/php-5.0.0(shutdown_memory_manager+0x5f)[0x5b4faf] /bin/php-5.0.0(php_request_shutdown+0x1df)[0x592c5f] /bin/php-5.0.0(main+0x584)[0x43fc44] /usr/lib/libc.so.6(__libc_start_main+0xf0)[0x7f637cf53710] /bin/php-5.0.0[0x44067d] ======= Memory map: ======== 00400000-007c9000 r-xp 00000000 00:00 0 007c9000-009c9000 ---p 00000000 00:00 0 009c9000-009f8000 rwxp 00000000 00:00 0 00a00000-00a01000 rwxp 00000000 00:00 0 011e0000-012f3000 rwxp 00000000 00:00 0 [heap] 7f6378000000-7f6378021000 rwxp 00000000 00:00 0 7f6378021000-7f637c000000 ---p 00000000 00:00 0 7f637c6b6000-7f637c6cc000 r-xp 00000000 00:13 7782 /usr/lib/libgcc_s.so.1 7f637c6cc000-7f637c8cb000 ---p 00016000 00:13 7782 /usr/lib/libgcc_s.so.1 7f637c8cb000-7f637c8cc000 rwxp 00015000 00:13 7782 /usr/lib/libgcc_s.so.1 7f637c8d9000-7f637c8e4000 r-xp 00000000 00:13 7901 /usr/lib/libnss_files-2.23.so 7f637c8e4000-7f637cae3000 ---p 0000b000 00:13 7901 /usr/lib/libnss_files-2.23.so 7f637cae3000-7f637cae4000 r-xp 0000a000 00:13 7901 /usr/lib/libnss_files-2.23.so 7f637cae4000-7f637cae5000 rwxp 0000b000 00:13 7901 /usr/lib/libnss_files-2.23.so 7f637cae5000-7f637caef000 rwxp 00000000 00:00 0 7f637caef000-7f637cb07000 r-xp 00000000 00:13 7927 /usr/lib/libpthread-2.23.so 7f637cb07000-7f637cd06000 ---p 00018000 00:13 7927 /usr/lib/libpthread-2.23.so 7f637cd06000-7f637cd07000 r-xp 00017000 00:13 7927 /usr/lib/libpthread-2.23.so 7f637cd07000-7f637cd08000 rwxp 00018000 00:13 7927 /usr/lib/libpthread-2.23.so 7f637cd08000-7f637cd0c000 rwxp 00000000 00:00 0 7f637cd0c000-7f637cd31000 r-xp 00000000 00:13 7870 /usr/lib/liblzma.so.5.2.2 7f637cd31000-7f637cf30000 ---p 00025000 00:13 7870 /usr/lib/liblzma.so.5.2.2 7f637cf30000-7f637cf31000 r-xp 00024000 00:13 7870 /usr/lib/liblzma.so.5.2.2 7f637cf31000-7f637cf32000 rwxp 00025000 00:13 7870 /usr/lib/liblzma.so.5.2.2 7f637cf32000-7f637cf33000 rwxp 00000000 00:00 0 7f637cf33000-7f637d0cb000 r-xp 00000000 00:13 7737 /usr/lib/libc-2.23.so 7f637d0cb000-7f637d2ca000 ---p 00198000 00:13 7737 /usr/lib/libc-2.23.so 7f637d2ca000-7f637d2ce000 r-xp 00197000 00:13 7737 /usr/lib/libc-2.23.so 7f637d2ce000-7f637d2d0000 rwxp 0019b000 00:13 7737 /usr/lib/libc-2.23.so 7f637d2d0000-7f637d2d4000 rwxp 00000000 00:00 0 7f637d2d4000-7f637d432000 r-xp 00000000 00:13 8004 /usr/lib/libxml2.so.2.9.3 7f637d432000-7f637d631000 ---p 0015e000 00:13 8004 /usr/lib/libxml2.so.2.9.3 7f637d631000-7f637d639000 r-xp 0015d000 00:13 8004 /usr/lib/libxml2.so.2.9.3 7f637d639000-7f637d63b000 rwxp 00165000 00:13 8004 /usr/lib/libxml2.so.2.9.3 7f637d63b000-7f637d63c000 rwxp 00000000 00:00 0 7f637d63c000-7f637d651000 r-xp 00000000 00:13 7896 /usr/lib/libnsl-2.23.so 7f637d651000-7f637d850000 ---p 00015000 00:13 7896 /usr/lib/libnsl-2.23.so 7f637d850000-7f637d851000 r-xp 00014000 00:13 7896 /usr/lib/libnsl-2.23.so 7f637d851000-7f637d852000 rwxp 00015000 00:13 7896 /usr/lib/libnsl-2.23.so 7f637d852000-7f637d855000 rwxp 00000000 00:00 0 7f637d855000-7f637d857000 r-xp 00000000 00:13 7755 /usr/lib/libdl-2.23.so 7f637d857000-7f637da57000 ---p 00002000 00:13 7755 /usr/lib/libdl-2.23.so 7f637da57000-7f637da58000 r-xp 00002000 00:13 7755 /usr/lib/libdl-2.23.so 7f637da58000-7f637da59000 rwxp 00003000 00:13 7755 /usr/lib/libdl-2.23.so 7f637da59000-7f637db5c000 r-xp 00000000 00:13 7872 /usr/lib/libm-2.23.so 7f637db5c000-7f637dd5c000 ---p 00103000 00:13 7872 /usr/lib/libm-2.23.so 7f637dd5c000-7f637dd5d000 r-xp 00103000 00:13 7872 /usr/lib/libm-2.23.so 7f637dd5d000-7f637dd5e000 rwxp 00104000 00:13 7872 /usr/lib/libm-2.23.so 7f637dd5e000-7f637dd72000 r-xp 00000000 00:13 7934 /usr/lib/libresolv-2.23.so 7f637dd72000-7f637df71000 ---p 00014000 00:13 7934 /usr/lib/libresolv-2.23.so 7f637df71000-7f637df72000 r-xp 00013000 00:13 7934 /usr/lib/libresolv-2.23.so 7f637df72000-7f637df73000 rwxp 00014000 00:13 7934 /usr/lib/libresolv-2.23.so 7f637df73000-7f637df76000 rwxp 00000000 00:00 0 7f637df76000-7f637df8b000 r-xp 00000000 00:13 8008 /usr/lib/libz.so.1.2.8 7f637df8b000-7f637e18a000 ---p 00015000 00:13 8008 /usr/lib/libz.so.1.2.8 7f637e18a000-7f637e18b000 r-xp 00014000 00:13 8008 /usr/lib/libz.so.1.2.8 7f637e18b000-7f637e18c000 rwxp 00015000 00:13 8008 /usr/lib/libz.so.1.2.8 7f637e18c000-7f637e194000 r-xp 00000000 00:13 7747 /usr/lib/libcrypt-2.23.so 7f637e194000-7f637e393000 ---p 00008000 00:13 7747 /usr/lib/libcrypt-2.23.so 7f637e393000-7f637e394000 r-xp 00007000 00:13 7747 /usr/lib/libcrypt-2.23.so 7f637e394000-7f637e395000 rwxp 00008000 00:13 7747 /usr/lib/libcrypt-2.23.so 7f637e395000-7f637e3c3000 rwxp 00000000 00:00 0 7f637e3cf000-7f637e3d0000 rwxp 00000000 00:00 0 7f637e3d0000-7f637e3d1000 r-xp 00000000 00:13 1726160 /usr/bin/daemon-preload.so 7f637e3d1000-7f637e5d0000 ---p 00001000 00:13 1726160 /usr/bin/daemon-preload.so 7f637e5d0000-7f637e5d1000 rwxp 00000000 00:13 1726160 /usr/bin/daemon-preload.so 7f637e5d1000-7f637e5d2000 rwxp 00000000 00:00 0 7f637e5d2000-7f637e5f5000 r-xp 00000000 00:13 7564 /usr/lib/ld-2.23.so 7f637e5f5000-7f637e7f5000 ---p 00000000 00:00 0 7f637e7f5000-7f637e7f6000 r-xp 00023000 00:13 7564 /usr/lib/ld-2.23.so 7f637e7f6000-7f637e7f7000 rwxp 00024000 00:13 7564 /usr/lib/ld-2.23.so 7f637e7f7000-7f637e7f8000 rwxp 00000000 00:00 0 7ffc8d4fa000-7ffc8d51b000 rwxp 00000000 00:00 0 [stack] 7ffc8d522000-7ffc8d525000 r--p 00000000 00:00 0 [vvar] 7ffc8d525000-7ffc8d527000 r-xp 00000000 00:00 0 [vdso] ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Process exited with code 134.
Output for 4.3.2 - 4.4.9
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/deXvE on line 20
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Cannot instantiate non-existent class: simplexmlelement in /in/deXvE on line 20