daknetworks.com

You are here: Blog eregi, preg_match | split, preg_split | ereg_replace, preg_replace

eregi, preg_match | split, preg_split | ereg_replace, preg_replace

Quick note to myself; eregi, ereg_replace and split are depreciated php functions. Official note is here:

http://www.php.net/manual/en/reference.pcre.pattern.posix.php

Fix eregi with preg_match like so:

case (eregi('android',$user_agent));  // we find android in the user agent
case (preg_match('/(android)/i',$user_agent));  // we find android in the user agent

if ( eregi( "bmp|gif|jpg|png|jpeg", $file ) && is_file( $i_f ) ) {^M
if ( preg_match( "/(bmp|gif|jpg|png|jpeg)/i", $file ) && is_file( $i_f ) ) {^M

if (eregi("0$", $count)) {
if ( preg_match( "/(0$)/i", $count)) {

if (eregi("gif", $file) || eregi("jpg", $file) || eregi("png", $file))
if (preg_match("/(gif)/i", $file) || preg_match("/(jpg)/i", $file) || preg_match("/(png)/i", $file))

Fix split with preg_split like so:

split(':', $thumbSpace);^M
preg_split('/:/', $thumbSpace);^M

split('www', 'D:/Projects/job.com/www/www/path/source', 2);
preg_split('/www/', 'D:/Projects/job.com/www/www/path/source', 2);

Fix ereg_replace with preg_replace like so:

$output = ereg_replace (";", "", $output);
$output = preg_replace ("/;/", "", $output);

Contact Dak Networks

We are not taking on new clients at this time.