Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $nickname = "xISRAPILx";
- $balance = 150000;
- $clan = "CloudMine";
- $text = "Привет, {NICKNAME}, ваш баланс: {BALANCE}, Ваш клан: {CLAN}";
- $keys = ["{NICKNAME}", "{BALANCE}", "{CLAN}"];
- $values = [$nickname, $balance, $clan];
- $key_values = ["{BALANCE}" => $balance, "{NICKNAME}" => $nickname, "{CLAN}" => $clan];
- $startTime = microtime(true);
- for($i = 0; $i < 500000; $i++){
- str_replace($keys, $values, $text);
- }
- echo "500000 str_replace + keys array + values array: ".round(microtime(true) - $startTime, 5).PHP_EOL;
- $startTime = microtime(true);
- for($i = 0; $i < 500000; $i++){
- str_replace(array_keys($key_values), array_values($key_values), $text);
- }
- echo "500000 str_replace + array_keys + array+values: ".round(microtime(true) - $startTime, 5).PHP_EOL;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement