Results 1 to 7 of 7
-
07-01-2012, 09:58 AM #1
Sophomore
- Join Date
- Aug 2011
- Posts
- 68
- Thanks
- 0
- Thanked 0 Times in 0 Posts
- Feedback Score
- 0
Best way to strip "http://" in simple PHP code
I have a code like this:
<div class="left">© <a href="<?php bloginfo('url'); ?>">="<?php bloginfo('url'); ?></a> | <a href="<?php bloginfo('url'); ?>/sitemap_index.xml">Sitemap</a></div>
, and it is showing the following result:
C http://domain-name.com | Stemap
I am wondering if there is any simple way to get rid of "http://" string using PHP ("inline", without using variables etc, like in some tutorials online)
Thank you.
-
07-02-2012, 10:50 AM #2
Freshman
- Join Date
- Jul 2012
- Posts
- 4
- Thanks
- 0
- Thanked 1 Time in 1 Post
- Feedback Score
- 0
Lets see if I understand you here. You want to take bloginfo("url") and strip off some text?
You can use str_replace(arg1,arg2,arg3). It has 3 arguments.
arg1 = the string to replace, put this in quotes
arg2 = the string to replace it with, put this in qoutes
arg3 = the string you are searching and replacing text within, in this case bloginfo("url")
str_replace("something","",bloginfo("url"));
will simply strip "something" and replace it with nothing.
You'll need
<?php echo str_replace("something","",bloginfo("url")); ?>
You can find more info on the PHP website and searching for str_replace.
Hope that helps!
Andy at SEO Consult
-
07-04-2012, 12:59 PM #3
That should work I think. However by the looks of it the bloginfo function echos out its output. You may have to find that function and change echo to return.PHP Code:<?php echo str_replace("h t t p : / /","",bloginfo("url")); ?>
-
07-05-2012, 05:07 AM #4
Junior
- Join Date
- Feb 2012
- Posts
- 198
- Thanks
- 1
- Thanked 2 Times in 2 Posts
- Feedback Score
- 0
this seems to be WordPress..
you cannot use bloginfo() inside a str_replace because bloginfo() doesn't return anything it will just echo the requested data. you need to use get_bloginfo() instead..
PHP Code:<a href="<?php bloginfo('url'); ?>"><?php str_replace("http://", "", get_bloginfo('url')); ?></a>
-
07-29-2012, 01:30 AM #5
I have specialized in LAMP and much more with the US Navy and various corporations.
See my tutorial site in the re-making at http://crackfeed.com/
-
09-25-2012, 01:46 AM #6
Senior
- Join Date
- Mar 2012
- Posts
- 681
- Thanks
- 1
- Thanked 0 Times in 0 Posts
- Feedback Score
- 0
-
09-25-2012, 01:49 AM #7
Senior
- Join Date
- Mar 2012
- Posts
- 681
- Thanks
- 1
- Thanked 0 Times in 0 Posts
- Feedback Score
- 0
We can use replace str function for remove this.
Similar Threads
-
HostPlate.com((NL)-"1Gbps 100TB" "100Mbps Unmetered","Dual Core" &"Quad Core"From €30
By hostplate in forum Other Hosting OffersReplies: 0Last Post: 11-06-2011, 12:58 PM -
HostPlate.com((NL)-"1Gbps 100TB" "100Mbps Unmetered","Dual Core" &"Quad Core"From €30
By hostplate in forum Other Hosting OffersReplies: 0Last Post: 10-31-2011, 08:19 AM -
HostPlate.com((NL)-"1Gbps 100TB" "100Mbps Unmetered","Dual Core" &"Quad Core"From €30
By hostplate in forum Other Hosting OffersReplies: 0Last Post: 10-22-2011, 12:37 PM -
HostPlate.com((NL)-"1Gbps 100TB" "100Mbps Unmetered","Dual Core" &"Quad Core"From €30
By hostplate in forum Other Hosting OffersReplies: 0Last Post: 10-15-2011, 02:52 PM -
Why GOOGLE CHROME hides "http://" for any webpage requested in it ?
By rhinestone in forum Computer and TechReplies: 1Last Post: 09-08-2011, 10:24 AM



Reply With Quote



