# Replace function in PHP

**URL:** <https://forum.kirupa.com/t/replace-function-in-php/201936>\
**Category:** programming\
**Created:** [September 26, 2006, 12:32pm UTC](https://forum.kirupa.com/t/replace-function-in-php/201936 "2006-09-26T12:32:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![opel](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/opel/32/199_2.png) [@opel](https://forum.kirupa.com/u/opel)\
**Post date:** [September 26, 2006, 12:32pm UTC](https://forum.kirupa.com/t/replace-function-in-php/201936/1 "2006-09-26T12:32:19Z")

</div>

I am trying to write out links to a page to make a link list from a MySql DB. I want to make sure that all the links are consistant and write out [http://www.site.com](http://www.site.com) into the href tags.

As the user has the ability to copy and past links into the admin section there may be some rows that have the link Url as [http://www](http://www). and others that are just www.

What I want to know is what function is best to use in PHP for removing the first instance of “http://” in a string. In ASP it would be written as

```auto
<a href="http://<%=replace(rsLinks.Fields.Item("LinkURL").Value,"http://","")%>" 

```

just need to know how to do it in PHP, any help is appreciated.
