Compy Posted May 29, 2008 Share Posted May 29, 2008 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 https://forums.phpfreaks.com/topic/107731-parsing-array-string-to-remove-http-from-url/ Share on other sites More sharing options...
PromaneX Posted May 29, 2008 Share Posted May 29, 2008 <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 https://forums.phpfreaks.com/topic/107731-parsing-array-string-to-remove-http-from-url/#findComment-552467 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.