0

Good afternoon.

What I'm trying to do is to get the username from the beginning of a field of data

example 'username Membership Fee' or 'Username29473 Membership Fee'

What I need to do is just get the 'username' or the 'Username29473' extracted as a value in a variable of it's own...

Know it has to be easy, but drawing a total blank, and working against the clock (as usual)

thanks in advance.

Douglas

3
Contributors
3
Replies
4
Views
4 Years
Discussion Span
Last Post by diafol
1
$string = 'username Membership Fee' or 'Username29473 Membership Fee';
$string = explode(' ', $string);
$username = $string[0];
0

Yep, that is it, thank you...

Always seem to draw a blank when I am in a rush.

1

There are variations on a theme:

$string = 'username Membership Fee';
echo strtok($string, " ");

$string = 'username Membership Fee';
echo strstr($string, ' ', true);

$string = 'username Membership Fee';
echo current(explode(' ', trim($string)));
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.