3v4l.org

run code in 500+ PHP versions simultaneously
<?php function parsePrintR(string $printRString): array { $printRString = trim($printRString); // Remove o texto inicial 'Array' e o parêntese de abertura if (stripos($printRString, 'Array') === 0) { $printRString = substr($printRString, strpos($printRString, '(') + 1); // Remove o último parêntese de fechamento correspondente $printRString = substr($printRString, 0, strrpos($printRString, ')')); } $result = []; $len = strlen($printRString); $i = 0; while ($i < $len) { // Ignora espaços e quebras de linha while ($i < $len && (ctype_space($printRString[$i]) || $printRString[$i] === "\n")) { $i++; } if ($i >= $len) break; // Busca chave entre colchetes if ($printRString[$i] === '[') { $i++; $key = ''; while ($i < $len && $printRString[$i] !== ']') { $key .= $printRString[$i++]; } $i++; // pula o ']' // pula espaços while ($i < $len && ctype_space($printRString[$i])) $i++; // espera '=>' if (substr($printRString, $i, 2) === '=>') { $i += 2; while ($i < $len && ctype_space($printRString[$i])) $i++; // Verifica se é um array if (stripos(substr($printRString, $i, 5), 'Array') === 0) { $i += 5; while ($i < $len && ctype_space($printRString[$i])) $i++; if ($printRString[$i] === '(') { $i++; $start = $i; $depth = 1; while ($i < $len && $depth > 0) { if ($printRString[$i] === '(') $depth++; if ($printRString[$i] === ')') $depth--; $i++; } $subArrayStr = substr($printRString, $start, $i - $start - 1); $result[$key] = parsePrintR('Array(' . $subArrayStr . ')'); } } else { // Valor simples $value = ''; // Lê até o fim da linha ou até encontrar um novo [key] while ($i < $len && $printRString[$i] !== "\n") { $value .= $printRString[$i++]; } $result[$key] = trim($value); } } } else { // ignora linhas que não começam com chave while ($i < $len && $printRString[$i] !== "\n") $i++; $i++; } } return $result; } $input = "Erro ao enviar o ipn: \nParams: Array\n(\n [0] => Array\n (\n [order] => abcde\n [payment_method] => C\n [payment_status] => A\n [xppmaster] => 123\n [hmac] => qwee123\n [payment_email] => 0\n [amount_paid] => 152.34\n [authorization_code] => 1234\n [apply_discount_into_checkout] => 0\n [only_update_order] => 1\n [cc_auth] => 2\n )\n\n [1] => Array\n (\n [id] => 213215421521\n [por_hora] => 2025-08-25 22:42:28\n [x_reference] => abcde\n [merchants_id] => 571\n [checkout_id] => 312341214\n [payment_method] => C\n [payment_status] => W\n [authorization_code] => 1234\n [utf8] => \n [authenticity_token] => \n [x_account_id] => avwdegfeeg\n [x_amount] => 152.34\n [x_pag_fee_applied] => 0\n [x_currency] => BRL\n [x_discount_type] => \n [x_discount] => \n [x_subtotal_discount] => \n [x_url_callback] => url.site.com\n [x_url_complete] => url.site.com\n [x_checkout_token] => aveofwjifw\n [x_order_id_shopify] => 1234\n [x_is_recurring] => 0\n [x_original_order] => \n [x_recurring_created_at] => \n [x_recurring_integrated_at] => \n [x_shop_country] => BR\n [x_shop_name] => \n [x_transaction_type] => \n [x_test] => false\n [x_customer_first_name] => João\n [x_customer_last_name] => doe\n [x_customer_email] => mail@mail.com\n [x_customer_phone] => 123421325421\n [x_customer_billing_country] => BR\n [x_customer_billing_first_name] => João\n [x_customer_billing_last_name] => doe\n [x_customer_billing_city] => Belo Horizonte\n [x_customer_billing_company] => 02991215690\n [x_customer_billing_address1] => Av. dadwwd, WJ1964\n [x_customer_billing_address2] => 7° andar, WJFuncionários\n [x_customer_billing_state] => Minas Gerais\n [x_customer_billing_zip] => 11111-3333\n [x_customer_billing_phone] => 123421325421\n [x_customer_shipping_country] => BR\n [x_customer_shipping_first_name] => João\n [x_customer_shipping_last_name] => doe\n [x_customer_shipping_city] => Belo Horizonte\n [x_customer_shipping_company] => 32321442141\n [x_customer_shipping_address1] => Av. dadwwd, WJ1964\n [x_customer_shipping_address2] => 7° andar, WJFuncionários\n [x_customer_shipping_state] => Minas Gerais\n [x_customer_shipping_zip] => 123213123-33333\n [x_customer_shipping_phone] => 123421325421\n [x_invoice] => \n [x_amount_shipping] => \n [x_amount_tax] => \n [x_description] => Products\n [x_url_cancel] => \n [x_signature] => \n [x_timestamp] => \n [x_fallback_payment] => \n [locale] => \n [commit] => \n [info_discounts_applied_into_checkout] => \n [pix_expiration_date] => \n [pix_expiration_time] => \n [pix_code] => \n [pix_image] => \n [boleto_url] => \n [boleto_expiration_date] => \n [nsu] => 1234\n [tid] => 8adwadwawafwafwaf\n [processed_by_google_pay] => 0\n [note_attribute_updated] => 0\n [processed_by_apple_pay] => 0\n [conciliate_at] => \n [payment_status_verified_at] => \n [pix_rec_id] => \n [x_merchantid] => 123\n [pix_order_pending] => 0\n [pix_thank_you_page] => 0\n )\n\n [2] => Array\n (\n [x_account_id] => avwdegfeeg\n [x_amount] => 152.34\n [x_currency] => BRL\n [x_gateway_reference] => ba123452025-08-26T01:46:08Z157230\n [x_message] => Payment Method: Cartão de crédito\n [x_reference] => abcde\n [x_result] => completed\n [x_test] => false\n [x_timestamp] => 2025-08-26T01:46:08Z\n [x_signature] => abvfefsfesf\n )\n\n)\n\nError: Error in sendIpnToShopify: Error in resolvePaymentStatusToPending: Error ao fazer a mutation de paymentSessionPending: \nArray\n(\n [0] => Array\n (\n [field] => Array\n (\n [0] => id\n )\n\n [message] => Payment session has already been resolved\/rejected, has already been pended with a different reason, or the response to start_payment_session request has not been received.\n )\n\n)\n"; $string = $input; // 1. Isolar os blocos de "Array(...)" da sua string de log preg_match_all('/Array\s*\((.|\n)*?\)\s*\n/s', $string, $arrayBlocks); //print_r($arrayBlocks); $jsonResults = []; foreach ($arrayBlocks[0] as $i => $block) { // echo "Começando index $i " . PHP_EOL; // echo PHP_EOL; // print_r($block); // echo PHP_EOL; // 2. Para cada bloco encontrado, converte para array $phpArray = parsePrintR($block); // 3. Adiciona ao resultado $jsonResults[] = $phpArray; } // 4. Converte o resultado final para JSON formatado $finalJson = json_encode($jsonResults, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); print_r($finalJson);

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.60.0120.00717.04
8.5.50.0050.00416.99
8.5.30.0120.00618.27
8.5.20.0110.01020.51
8.5.10.0120.00616.70
8.5.00.0110.01123.17
8.4.210.0080.00320.09
8.4.180.0160.00720.01
8.4.170.0110.01024.26
8.4.160.0050.00622.25
8.4.150.0070.00617.01
8.4.140.0110.01218.23
8.4.130.0110.01118.09
8.4.120.0080.00520.98
8.4.110.0180.01017.98
8.4.100.0160.00318.00
8.4.90.0220.00417.90
8.4.80.0190.00218.08
8.4.70.0170.00418.26
8.4.60.0180.00517.66
8.4.50.0160.00618.13
8.4.40.0220.00117.73
8.4.30.0190.00518.08
8.4.20.0180.00617.58
8.4.10.0180.00417.80
8.3.300.0100.01120.95
8.3.290.0170.00620.70
8.3.280.0120.00918.73
8.3.270.0090.01017.07
8.3.260.0120.00817.10
8.3.250.0150.00816.74
8.3.240.0180.00417.05
8.3.230.0180.00416.94
8.3.220.0150.00816.63
8.3.210.0150.00516.63
8.3.200.0200.00316.99
8.3.190.0180.00316.92
8.3.180.0150.00616.37
8.3.170.0220.00216.44
8.3.160.0190.00516.87
8.3.150.0190.00316.82
8.3.140.0190.00416.93
8.3.130.0190.00316.88
8.3.120.0150.00416.31
8.3.110.0150.00616.59
8.3.100.0170.00516.69
8.3.90.0180.00317.09
8.3.80.0190.00416.58
8.3.70.0180.00516.75
8.3.60.0180.00516.92
8.3.50.0190.00517.07
8.3.40.0200.00317.65
8.3.30.0150.00517.90
8.3.20.0130.00317.52
8.3.10.0120.00617.68
8.3.00.0080.00417.95
8.2.300.0100.01120.50
8.2.290.0110.00616.46
8.2.280.0150.00416.54
8.2.270.0150.00516.96
8.2.260.0140.00516.66
8.2.250.0160.00316.66
8.2.240.0140.00516.46
8.2.230.0190.00216.82
8.2.220.0120.00616.84
8.2.210.0170.00216.63
8.2.200.0150.00516.69
8.2.190.0150.00316.55
8.2.180.0140.00417.06
8.2.170.0160.00417.76
8.2.160.0140.00617.73
8.2.150.0200.00017.81
8.2.140.0160.00517.86
8.2.130.0140.00417.71
8.2.120.0140.00517.89
8.2.110.0140.00517.80
8.2.100.0140.00517.64
8.2.90.0150.00417.65
8.2.80.0150.00517.84
8.2.70.0130.00617.87
8.2.60.0190.00217.76
8.2.50.0160.00417.73
8.2.40.0200.00317.68
8.2.30.0140.00517.93
8.2.20.0160.00317.57
8.2.10.0140.00417.74
8.2.00.0140.00417.60
8.1.340.0100.00921.95

preferences:
52.57 ms | 1202 KiB | 5 Q