3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str=<<<XML <database name="newsportal"> <table name="wp_options"> <column name="option_id">1</column> <column name="option_name">siteurl</column> <column name="option_value">http://localhost/newsportal</column> <column name="autoload">yes</column> </table> <table name="wp_options"> <column name="option_id">2</column> <column name="option_name">home</column> <column name="option_value">http://localhost/newsportal</column> <column name="autoload">yes</column> </table> <table name="wp_options"> <column name="option_id">3</column> <column name="option_name">blogname</column> <column name="option_value">News Portal</column> <column name="autoload">yes</column> </table> <table name="wp_options"> <column name="option_id">4</column> <column name="option_name">blogdescription</column> <column name="option_value">Just another WordPress site</column> <column name="autoload">yes</column> </table> </database> XML; $xml=simplexml_load_string($str); $nodes = $xml->xpath("//database//table[@name='wp_options']"); foreach($nodes as $item) { $row = simplexml_load_string($item->asXML()); $v = $row->xpath("//column[@name='option_id'][.=('1' '2' '3')]"); if(count($v) > 0) { foreach($item->column as $column) { echo $column['name'] . '=' . $column . "<br/>"; } //echo $item->column['name']."<br/>"; } }
Output for 8.3.0 - 8.3.4
Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, false given in /in/1qYAR:39 Stack trace: #0 {main} thrown in /in/1qYAR on line 39
Process exited with code 255.
Output for 8.0.10 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17
Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, bool given in /in/1qYAR:39 Stack trace: #0 {main} thrown in /in/1qYAR on line 39
Process exited with code 255.
Output for 8.0.0 - 8.0.9
Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, bool given in /in/1qYAR:39 Stack trace: #0 {main} thrown in /in/1qYAR on line 39
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 Warning: count(): Parameter must be an array or an object that implements Countable in /in/1qYAR on line 39 option_id=1<br/>option_name=siteurl<br/>option_value=http://localhost/newsportal<br/>autoload=yes<br/> Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 Warning: count(): Parameter must be an array or an object that implements Countable in /in/1qYAR on line 39 option_id=2<br/>option_name=home<br/>option_value=http://localhost/newsportal<br/>autoload=yes<br/> Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 Warning: count(): Parameter must be an array or an object that implements Countable in /in/1qYAR on line 39 option_id=3<br/>option_name=blogname<br/>option_value=News Portal<br/>autoload=yes<br/> Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 Warning: count(): Parameter must be an array or an object that implements Countable in /in/1qYAR on line 39 option_id=4<br/>option_name=blogdescription<br/>option_value=Just another WordPress site<br/>autoload=yes<br/>
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 option_id=1<br/>option_name=siteurl<br/>option_value=http://localhost/newsportal<br/>autoload=yes<br/> Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 option_id=2<br/>option_name=home<br/>option_value=http://localhost/newsportal<br/>autoload=yes<br/> Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 option_id=3<br/>option_name=blogname<br/>option_value=News Portal<br/>autoload=yes<br/> Warning: SimpleXMLElement::xpath(): Invalid expression in /in/1qYAR on line 37 Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in /in/1qYAR on line 37 option_id=4<br/>option_name=blogdescription<br/>option_value=Just another WordPress site<br/>autoload=yes<br/>

preferences:
138.98 ms | 404 KiB | 178 Q