Re: Finding numerical values in a string

From: Date: Thu, 31 Aug 2000 12:20:01 +0000
Subject: Re: Finding numerical values in a string
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-14566@lists.php.net to get a copy of this message
Dana.Reed@clinicaldatacare.com wrote: > There's probably a more eloquent way to do this, but IF you know the length of the part > before the number you could use substr to return the rest. > So, if all $foo values begin with "notavail" you could use: > if ( $Pid == "notavail".substr($foo,8) ) { > ... > } Clean way would be e.g. preg_match("/(\d+)$/", $string, $matches); $num = $matches[1]; -- | Heikki Korpela | heikki.korpela@wapit.com | tel. +358 50 3838 609 | | Software Developer, Wapit Finland | http://www.wapit.com | -- "/dev/clue was linked to /dev/null"

« previous php.general (#14566) next »