3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = [ 0 => [ "product_id" => 219, "product_description" => "<table style=\"color:; text-align: left;\"> <tr> <td> Processor: </td> <td> Intel Core 2 Duo - E8400 </td> </tr> <tr> <td> Clock speed: </td> <td> 3.0 GHz </td> </tr> <tr> <td> Memory: </td> <td> 4 GB </td> </tr> <tr> <td> Hard disk: </td> <td> 250 GB </td> </tr> <tr> <td> Video-adapter: </td> <td> VGA, Display </td> </tr> <tr> <td> Netwerk card: </td> <td> 1000 Mbps LAN </td> </tr> <tr> <td> Optical drive: </td> <td> DVD-Rewriter </td> </tr> <tr> <td> Operating system: </td> <td> Windows 7 or 10 Pro </td> </tr> <tr> <td> Warranty: </td> <td> 1 year </td> </tr> </table>"] ]; $arr = array_pop($a); $str = $arr["product_description"]; $stripped = strip_tags( $str, "<td>" ); $replaced = str_replace( "</td>", "", $stripped ); $arr = explode( "<td>", $replaced ); array_shift( $arr ); $arrKeyVal=[]; for( $i=0, $max = count( $arr ); $i < $max; $i+=2 ) { $key = trim( $arr[$i],"\r\t\n :" ); $arrKeyVal[strtolower( $key )] = trim( $arr[$i+1] ); } print_r( $arrKeyVal );
Output for 7.0.0 - 7.0.26, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.27, 8.4.1 - 8.4.14
Array ( [processor] => Intel Core 2 Duo - E8400 [clock speed] => 3.0 GHz [memory] => 4 GB [hard disk] => 250 GB [video-adapter] => VGA, Display [netwerk card] => 1000 Mbps LAN [optical drive] => DVD-Rewriter [operating system] => Windows 7 or 10 Pro [warranty] => 1 year )

preferences:
113.87 ms | 408 KiB | 5 Q