3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sourcestring='part "C28" { type : "1AB010050093", %cadtype : "1AB010050094", shapeid : "2_1206", descr : "4700.0000 pFarad 10.00 % 100.0 - VE5-VS3", insclass : "CP6A,CP6B", gentype : "RECT_032_016_006", machine : "SMT", %package : "080450E", %_item_number: "508", %_Term_Seq : "" } part "C29" { type : "1AB008140029", shapeid : "2_1206", descr : "150.0000 pFarad 5.00 % 100.0 Volt NP0 CERAMIC CAPACITOR", insclass : "CP6A,CP6B", gentype : "RECT_032_016_006", machine : "SMT", %package : "080450E", %_item_number: "3", %_Term_Seq : "" } part "C30" { type : "1AB0081400 30", shapeid : "2_1206 30", insclass : "CP6A,CP6B 30", gentype : "RECT_032_016_006 30", machine : "SMT 30", %package : "080450E 30 ", %_item_number: "3 30 ", %_Term_Seq : "30" }'; preg_match_all('/^part\s"(?P<ref>[^"]*)"[^{]*{ (?:(?=[^}]*\sdescr\s*:\s+"(?P<descr>[^"]*)"))? (?=[^}]*\stype\s*:\s+"(?P<partnumber>[^"]*)")/imsx',$sourcestring,$matches); echo "<pre>".print_r($matches,true); ?>
Output for 4.3.3 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 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.37, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.17 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
<pre>Array ( [0] => Array ( [0] => part "C28" { [1] => part "C29" { [2] => part "C30" { ) [ref] => Array ( [0] => C28 [1] => C29 [2] => C30 ) [1] => Array ( [0] => C28 [1] => C29 [2] => C30 ) [descr] => Array ( [0] => 4700.0000 pFarad 10.00 % 100.0 - VE5-VS3 [1] => 150.0000 pFarad 5.00 % 100.0 Volt NP0 CERAMIC CAPACITOR [2] => ) [2] => Array ( [0] => 4700.0000 pFarad 10.00 % 100.0 - VE5-VS3 [1] => 150.0000 pFarad 5.00 % 100.0 Volt NP0 CERAMIC CAPACITOR [2] => ) [partnumber] => Array ( [0] => 1AB010050093 [1] => 1AB008140029 [2] => 1AB0081400 30 ) [3] => Array ( [0] => 1AB010050093 [1] => 1AB008140029 [2] => 1AB0081400 30 ) )
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 <pre>Array ( [0] => Array ( [0] => part "C28" { [1] => part "C29" { [2] => part "C30" { ) [ref] => Array ( [0] => C28 [1] => C29 [2] => C30 ) [1] => Array ( [0] => C28 [1] => C29 [2] => C30 ) [descr] => Array ( [0] => 4700.0000 pFarad 10.00 % 100.0 - VE5-VS3 [1] => 150.0000 pFarad 5.00 % 100.0 Volt NP0 CERAMIC CAPACITOR [2] => ) [2] => Array ( [0] => 4700.0000 pFarad 10.00 % 100.0 - VE5-VS3 [1] => 150.0000 pFarad 5.00 % 100.0 Volt NP0 CERAMIC CAPACITOR [2] => ) [partnumber] => Array ( [0] => 1AB010050093 [1] => 1AB008140029 [2] => 1AB0081400 30 ) [3] => Array ( [0] => 1AB010050093 [1] => 1AB008140029 [2] => 1AB0081400 30 ) )
Output for 4.3.0 - 4.3.2
<pre>Array ( [0] => Array ( [0] => part "C28" { [1] => part "C29" { [2] => part "C30" { ) [1] => Array ( [0] => C28 [1] => C29 [2] => C30 ) [2] => Array ( [0] => 4700.0000 pFarad 10.00 % 100.0 - VE5-VS3 [1] => 150.0000 pFarad 5.00 % 100.0 Volt NP0 CERAMIC CAPACITOR [2] => ) [3] => Array ( [0] => 1AB010050093 [1] => 1AB008140029 [2] => 1AB0081400 30 ) )

preferences:
277.62 ms | 403 KiB | 376 Q