Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   How to add < href to PHP? (https://www.warriorforum.com/programming/496889-how-add-href-php.html)

iisark 1st December 2011 06:52 PM

How to add < href to PHP?
 
Hi to all,
I need help with this line of code
$data[1]["Category"]["body"] = str_replace("[!LOCATION!]", $data[2]["Location"]["name"], " ".$data[1]["Category"]["name"]." text text text ".$data[1]["Category"]["name"]." text text text");

I want to add <href link to this line of code (where the "text" words are),so it shoud look something like this:

$data[1]["Category"]["body"] = str_replace("[!LOCATION!]", $data[2]["Location"]["name"], " ".$data[1]["Category"]["name"]." text text LINK GOES HERE text ".$data[1]["Category"]["name"]." text text text");

I added: "LINK GOES HERE" beacuse i 'm not allowed to post links

But when i add the link,my site collapse
Can you please help me with that?

ussher 1st December 2011 08:17 PM

Re: How to add < href to PHP?
 
The code you have there looks for ['!LOCATION'] and if it finds that text it replaces it with the value in the $data[2]["Location"]["name"]

please explain "my site collapse"

If its a fixed link that doesn't change im guessing that your issue is probably non-escaped quotes.

the " are stuffing things up because <a href="link to someoehrere">the link</a> has quotes in it.

Try using single quotes ' or escaping them with a backslash (depending on what language it is)
<a href=\"link to someoehrere\">the link</a>

rainso0 2nd December 2011 01:18 AM

Re: How to add < href to PHP?
 
Yes. There are many ways. One of them is:

<html>
<?php
echo '<b>' . htmlspecialchars( $name ) . '</b>,<br />';
echo 'Sorry there's a problem sending your message. ';
echo 'Please <a href="/mail.html">try again</a>.';
?>
</html>

another:

<html>
<b><?php htmlspecialchars( $name ); ?></b>,<br />
Sorry there's a problem sending your message.
Please <a href="/mail.html">try again</a>.
</html>


All times are GMT -6. The time now is 07:32 AM.