Jump to content

How to extract only first alphabetical characters from a string


geroido

Recommended Posts

Hi

I have entries in my database that look like the following:

 

lynnie20080825122012

geroido20080825105322

lynnie20080825112208

geroido20080825122526

 

They are all unique entries. What I want to do is to extract only the first alphabetical part of the string and nothing else. So I would end up with:

 

lynnie

geroido

lynnie

geroido

 

Any ideas how I might do this?

 

Ok as you get the data from a database, i'm going for a full example:

 

<?php
$results = mysql_query("SELECT username FROM users");
while($values = mysql_fetch_array($results)){
     $user = preg_replace('/[0-9]/', '', $values['user']);
     echo $user;
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.