Jump to content

Recommended Posts

I have a news database and i was wondering if i could somehow make it where when if fetches the array if it could search it and put it in a <a href=$link >$link</a> and make it where if it allready has the tag <a href= > and </a> then do nothing this is probably a longer anwser but if som1 could plz help that would be much appreciated
[code]
<?php
// assuming your data looks like this vs. this:
// http://www.blah.com vs. <a href='http://www.blah.com'>http://www.blah.com</a>

// example
$data = "http://www.blah.com";

// data have '<a' in it already? do nothing. It doesn't? add it on
$data = (stripos($data, "<a")) ? $data :  "<a href = '$data'>$data</a>";
[/code]
uh..okay..well you didn't say anything about that in your OP.  And even now you're not being very specific.  The impression I got is that you have a chunk of data and it has a url in it somewhere but it may or may not have href tags around it, so if it doesn't, then wrap the url in href tags.  That's what my example does.  If you have an array of data, just put the code in a loop that checks each element.

How about you make an example list of what your actual data looks like and post it here, showing [i]every[/i] example of what it should look for and change, vs. not change.

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.