Jump to content

parsing array string to remove "http" from URL


Compy

Recommended Posts

Hi,

 

I have an array value which stores URLs which I print to the page.

It is currently printing the full URL incl. the "http://" part. I would like to strip this off when it displays the URL.

Here is the code:

 

 

   1. <a href="<?php echo $fieldsObjects['field_website']->data; ?>" target="_blank">
   2. <?php echo $fieldsObjects['field_website']->data; ?>
   3. </a>

 

 

Can anyone get me started on how to parse the 2nd line so that it strips off the leading part of the URL?

 

I would be greatly appreciation of this idea.

 

TIA,

 

Compy

Link to comment
Share on other sites

<a href="<?php echo str_replace("http://","",$fieldsObjects['field_website']->data); ?>" target="_blank">
<?php echo str_replace("http://","",$fieldsObjects['field_website']->data); ?>
</a>

 

doing that would be better than using regex in my opinion, why over-complicate things?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.