Author Topic: php help  (Read 2057 times)

Offline crnogorac081

  • Posts: 1908
  • Gender: Male
php help
« on: May 27, 2011, 04:39:09 PM »
Hi,

I could find a solution on web, or maybe I searched for a wrong term, but how can I wrap a link around text ?

for example, I have this code:
Code: [Select]
<a href="..."><div> some text...text ....text .</div></a> but it doesnt pass validation as I am wrapping block element with inline element. What I am trying to find is how to put a link over text only (inside div tags)
Code: [Select]
<div> <a href="...">some text...text ....text .</a></div>

any help would be much appreciated ;)
cheers,
Ivan
no bb in signature

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3025
  • Gender: Female
Re: php help
« Reply #1 on: May 27, 2011, 06:49:02 PM »
Block elements within Inline elements are not permitted.
You can handle it maybe, taking a <span> instead of the <div> and set it's display attribute to 'block' or 'inline-block'.
Without guaranty  :wink:
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf Hirn vom Himmel !

Offline crnogorac081

  • Posts: 1908
  • Gender: Male
Re: php help
« Reply #2 on: May 27, 2011, 07:06:48 PM »
i know,it is a part of template for the module I am working on, the text supposed to be a description, and I need to put a link on description, but then, if description text is aligned: center, I have a block element.. so I am wondering if some experience coder can help on this piece of code.. I found some simular examples with preg match or preg replace, but I havent found a solution for this :(

What I exactly need:
Code: [Select]
$link = '<a href="http://www...."> </a>';
$description = '<div> some <p>dummy text</p>...dummy text ....<span>text</span>......test.... .</div>';

Now I need function to locate pure text and put a link ( $link ) around each peace of text in $description

The result should be something like this:
$description = '<div> <a href="http://www....">some</a> <p><a href="http://www....">dummy text</a></p><a href="http://www....">...dummy text ....</a><span><a href="http://www....">text</a></span><a href="http://www....">......test....</a></div>';

« Last Edit: May 27, 2011, 07:21:51 PM by crnogorac081 »
no bb in signature