3v4l.org

run code in 300+ PHP versions simultaneously
<?php $pattern = "/(%\S*)/"; $replacement = "%s"; $input_str = "Controller '%d is potentially leaking. All controllers are supposed to have an empty reference count. If this is a non synch sound controller, then script will need to make sure to clean it up."; $messageParameters = ["CVSNyz368g="]; if (preg_match_all($pattern, $input_str, $matches_out)) { $printfCodes = $matches_out[1]; foreach ($printfCodes as $index => $printfCode) { if ($printfCode != "%s" && $printfCode != "%c") { $decodedIntAsString = $messageParameters[$index] . " translated!"; $messageParameters[$index] = $decodedIntAsString; } } if (count($printfCodes) == count($assert['Message Parameter'])) { $new_str = preg_replace($pattern, $replacement, $input_str); echo "swapped printfCodes: " . $new_str . "\n"; // Try and resolve the pfrintf statement using message parameters $resolvedAssert = vsprintf($new_str, $messageParameters); if (!empty($resolvedAssert) && $resolvedAssert != $new_str) { $final_str = $resolvedAssert; echo "finalStr " . $final_str . "\n"; } } } print_r( $messageParameters);

preferences:
54.45 ms | 402 KiB | 5 Q