user3512522
user3512522

Reputation: 39

Trying to remove all spaces from a field in WordPress

I have this line of code in WordPress:

a href="http://domain.com/<?php echo $member['ut_member_name']; ?>"

I want it to displace the field WITHOUT any of the spaces.

For example: http://domain.com/tomjones

The field is originally saved as "Tom Jones".

Any idea how I can do this...??

Thanx in advance.

Upvotes: 0

Views: 2696

Answers (3)

Vikram
Vikram

Reputation: 281

You may use the existing wordpress functions. Check at below link:

http://codex.wordpress.org/Function_Reference/sanitize_title_with_dashes

Upvotes: 0

user3651426
user3651426

Reputation:

try str_replace

$member_name = str_replace(" ","", $member['ut_member_name']);

Upvotes: 1

Eddie
Eddie

Reputation: 26844

How about this? strtolower(str_replace(" ","", $member['ut_member_name']));

This will remove all space and make all characters to lowercase.

Upvotes: 1

Related Questions