note 6318 deleted from function.ereg-replace by jimw

From: Date: Fri, 02 Nov 2001 01:48:08 +0000
Subject: note 6318 deleted from function.ereg-replace by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-20185@lists.php.net to get a copy of this message
I miss the way C treats strings as an array of characters. I want to zip through a string and remove every character that is not a number. I tried using ereg_replace( "[0-9]", "", $phone_number); but if $phone_number = "23test24"; the variable ends up being just 23 instead of 2324. This works:<br> $phone_number = ereg_replace("[^[:digit:]]","",$phone_number);

« previous php.notes (#20185) next »