3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string_original = " Ivq6T2IoWbLNCoru7RTv kcEDwTVDhkqRAePOOQsM c6pcDsaq1waWzuzNHAYl pqFRFt1XwSX6JBLslwDs VWygeUir8kWMOpU5RArI WZ1UCYybMhpetyaCCkiM 8OVqENVpWmCZvDyvq8dG PPxPs48xPuiaLGdKhjEl 2i5y2URwQlRS1pbrKDS5 euT3KHvPrhM5wnOyTpJv "; var_dump($string_original); $string = $string_original; $pattern = '%' # Select a digit and 5 letters after .'(\d)(\w{5})' .'%'; $string = preg_replace_callback( $pattern, function($matches){ # Add to one to digit and then lowercase 5 letters after. $matches[1] = $matches[1] + 1; $matches[2] = strtolower($matches[2]); return $matches[1].$matches[2]; }, $string); var_dump($string); $string = $string_original; $pattern = '%' # Any digit and after 5 alpha-numeric characters. .'(\d)(?<=\w{5})' .'%'; # Replace all integers to symbols $string = preg_replace_callback( $pattern, function($matches){ if($matches[1] >= 5){ return '_'; }else{ return '@'; } }, $string, # Limit only 2 replacements 2); var_dump($string); # Array Replacement $arr = [ 'IUjd5x13NF1OyQn9Afjy', 'S1BG0EhuWxr5icrgD1St', 'oLKV7cI6Qx5503K0eJ6U', 'V36IgE0TE6Qq6beBnJkC', 'jcMIKR9wk9u8kdN6UyPR', 'N8CNqZDQPJwLH87rnmKq', 'yeSAo75DcWQqQM9FynIu', 'QoRWAnP2G1LGkRoBbiud', 'tiVkR9UkIiB6ChI6l6Se', '9BWLYV7msRz7WsSADx7u' ]; $pattern = '%' # Any Digit after 10 characters .'(\d)(?<=\w{10})' .'%'; # Replace integers from <5 to _ and >5 to @ # Note the limit here works per line in the array. # And the count can be gathered via another variable declaration on the function. $arr = preg_replace_callback( $pattern, function($matches){ if($matches[1] >= 5){ return '_'; }else{ return '@'; } }, $arr, 1, $count); var_dump($arr); var_dump($count);
Output for git.master, git.master_jit, rfc.property-hooks
string(211) " Ivq6T2IoWbLNCoru7RTv kcEDwTVDhkqRAePOOQsM c6pcDsaq1waWzuzNHAYl pqFRFt1XwSX6JBLslwDs VWygeUir8kWMOpU5RArI WZ1UCYybMhpetyaCCkiM 8OVqENVpWmCZvDyvq8dG PPxPs48xPuiaLGdKhjEl 2i5y2URwQlRS1pbrKDS5 euT3KHvPrhM5wnOyTpJv " string(211) " Ivq7t2iowbLNCoru7RTv kcEDwTVDhkqRAePOOQsM c7pcdsaq2wawzuzNHAYl pqFRFt2xwsx6JBLslwDs VWygeUir9kwmopU5RArI WZ2ucyybMhpetyaCCkiM 9ovqenVpWmCZvDyvq8dG PPxPs58xpuiaLGdKhjEl 3i5y2uRwQlRS2pbrkdS5 euT4khvprhM6wnoytpJv " string(211) " Ivq6T@IoWbLNCoru_RTv kcEDwTVDhkqRAePOOQsM c6pcDsaq1waWzuzNHAYl pqFRFt1XwSX6JBLslwDs VWygeUir8kWMOpU5RArI WZ1UCYybMhpetyaCCkiM 8OVqENVpWmCZvDyvq8dG PPxPs48xPuiaLGdKhjEl 2i5y2URwQlRS1pbrKDS5 euT3KHvPrhM5wnOyTpJv " array(10) { [0]=> string(20) "IUjd5x13NF@OyQn9Afjy" [1]=> string(20) "S1BG0EhuWxr_icrgD1St" [2]=> string(20) "oLKV7cI6Qx_503K0eJ6U" [3]=> string(20) "V36IgE0TE_Qq6beBnJkC" [4]=> string(20) "jcMIKR9wk_u8kdN6UyPR" [5]=> string(20) "N8CNqZDQPJwLH_7rnmKq" [6]=> string(20) "yeSAo75DcWQqQM_FynIu" [7]=> string(20) "QoRWAnP2G@LGkRoBbiud" [8]=> string(20) "tiVkR9UkIiB_ChI6l6Se" [9]=> string(20) "9BWLYV7msRz_WsSADx7u" } int(10)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
68.79 ms | 404 KiB | 8 Q