3v4l.org

run code in 300+ PHP versions simultaneously
<?php $content = '/NameType /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02\'00\')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false'; if (preg_match('/^\s*\((?P<name>.*)/s', $content, $match)) { } $offset=0; if (preg_match('/^\s*(?P<name>\/[A-Z0-9\._]+)(?P<value>.*)/si', substr($content, $position), $match)) { print_r($match); } if (preg_match('/^\s*\((?P<name>.*)/s', $content, $match)) { $name = $match['name']; // Find next ')' not escaped. $cur_start_text = $start_search_end = 0; while (($cur_start_pos = strpos($name, ')/', $start_search_end)) !== false) { $cur_extract = substr($name, $cur_start_text, $cur_start_pos - $cur_start_text); preg_match('/(?P<escape>[\\\]*)$/s', $cur_extract, $match); if (!(strlen($match['escape']) % 2)) { break; } $start_search_end = $cur_start_pos + 1; } // Extract string. $name = substr($name, 0, $cur_start_pos); $offset += strpos($content, '(') + $cur_start_pos + 2; // 2 for '(' and ')' $name = str_replace( array('\\\\', '\\ ', '\\/', '\(', '\)', '\n', '\r', '\t'), array('\\', ' ', '/', '(', ')', "\n", "\r", "\t"), $name ); print_r($name); } // your code goes here echo "test";
Output for 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Warning: Undefined variable $position in /in/JckBO on line 10 Deprecated: substr(): Passing null to parameter #2 ($offset) of type int is deprecated in /in/JckBO on line 10 Array ( [0] => /NameType /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [name] => /NameType [1] => /NameType [value] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [2] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false ) test
Output for 8.0.0 - 8.0.30
Warning: Undefined variable $position in /in/JckBO on line 10 Array ( [0] => /NameType /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [name] => /NameType [1] => /NameType [value] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [2] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false ) test
Output for 5.0.4 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Notice: Undefined variable: position in /in/JckBO on line 10 Array ( [0] => /NameType /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [name] => /NameType [1] => /NameType [value] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [2] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false ) test
Output for 7.3.32 - 7.3.33
Array ( [0] => /NameType /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [name] => /NameType [1] => /NameType [value] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [2] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false ) test
Output for 4.3.3 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.3
Notice: Undefined variable: position in /in/JckBO on line 10 Array ( [0] => /NameType /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [name] => /NameType [1] => /NameType [value] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [2] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false ) test
Output for 4.3.0 - 4.3.2
Notice: Undefined variable: position in /in/JckBO on line 10 Array ( [0] => /NameType /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false [1] => /NameType [2] => /FlateDecode /Contents[4 0 R 42]/Fonts<</F1 41/F2 43>>/NullType null/StringType(hello))/DateType(D:20130901235555+02'00')/XRefType 2 0 R /NumericType 8/HexaType<0020>/BooleanType false ) test

preferences:
288.58 ms | 402 KiB | 456 Q