PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $letters = ['a','b','c', 'd', 'e']; $replace = [1, 5, 10, 15 , 20]; $text = "abd cde dee ae d"; echo preg_replace_callback( '/[a-e]+/', fn($m) => array_sum( str_replace( $letters, $replace, str_split($m[0]) ) ), $text );
Show:  
Copy Clear