Skip to content

Instantly share code, notes, and snippets.

@macik
Created December 25, 2012 11:26
Show Gist options
  • Save macik/4372764 to your computer and use it in GitHub Desktop.
Save macik/4372764 to your computer and use it in GitHub Desktop.
Converts old string PHP functions for multibyte anologs.
<?php
$filename = 'header.php'; // File name
$search[] = 'mail('; $replace[] = 'mb_send_mail(';
$search[] = 'strlen('; $replace[] = 'mb_strlen(';
$search[] = 'strpos('; $replace[] = 'mb_strpos(';
$search[] = 'strrpos('; $replace[] = 'mb_strrpos(';
$search[] = 'substr('; $replace[] = 'mb_substr(';
$search[] = 'strtolower('; $replace[] = 'mb_strtolower(';
$search[] = 'strtoupper('; $replace[] = 'mb_strtoupper(';
$search[] = 'stripos('; $replace[] = 'mb_stripos(';
$search[] = 'strstr('; $replace[] = 'mb_strstr(';
$search[] = 'stristr('; $replace[] = 'mb_stristr(';
$search[] = 'strrchr('; $replace[] = 'mb_strrchr(';
$search[] = 'substr_count('; $replace[] = 'mb_substr_count(';
$search[] = 'ereg('; $replace[] = 'mb_ereg(';
$search[] = 'eregi('; $replace[] = 'mb_eregi(';
$search[] = 'ereg_replace('; $replace[] = 'mb_ereg_replace(';
$search[] = 'eregi_replace('; $replace[] = 'mb_eregi_replace(';
$search[] = 'split('; $replace[] = 'mb_split(';
$file = file_get_contents($filename);
$file = str_replace($search,$replace,$file);
file_put_contents($filename,$file);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment