FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


substr not working?





welshsteve
Hi, I have a website with a database and I'm using PHP to pull the data in.

Its a sports website and I'm trying to bring in data for particular teams to screen. This is working fine except my data tables are names as follows:

T_Team_1
T_Team_2

etc. The T_ making it easier for me to see behind the scenes that its a table for a team.

In my php script I'm using some php functions to remove the underscores and the prefix, but it's not working.

Firstly I replace the prefix with nothing, then I replace the remaining underscores with spaces

Code:

$team = str_replace("T_","",$team);
$team = str_replace("_"," ",$team);


Then I display it using this coed

Code:

echo "<h2>Player Statistics for " . $team . "</h2>";


But what I'm getting to screen is:

T Team 1

So it is removing the underscores, but not the leading T.

I've even tried just removing the underscores, then using the following code to display. But this won't work either.

Code:

$team = str_replace("_"," ",$team);
echo "<h2>Player Statistics for " . substr($team,2) . "</h2>";


Is anybody able to help at all?
rickylau
Strange...It's working just as expected on my side. You might want to output the $team before and after every step to check where it goes wrong.
welshsteve
It's working now. Think it might have been a browser caching issue, but for some reason it's started to work. quite bizarre.

Thanks
Related topics
My Subdomain still not working :(
GD-library header probs
E-Cards with PHP & MySQL
Site Nav Suggestions...
site not working
My subdmain seems to be not working.
phpBB Not Working
[RESOLVED] Cpanel not working?
please provide feedback for http://sanghvitrades.frihost.net
[RESOLVED] Mailing list not working
domain name not working
[RESOLVED] trying to host a .com.au domain! help found!
Deleted public_html
Image Script not working.
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.