Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to put hyperlink value in variable?

Posted on 2008-06-17
9
Medium Priority
?
232 Views
Last Modified: 2010-04-21
Hi

I have one hyperlink title is "MyLink" which points to "http://domain.com/file/file.doc"

I want to store hyperlink value(http://domain.com/file/file.doc) in variable $target
so that i can simply print the text (not link) > http://domain.com/file/file.doc

===========
Also if you can help

i have [  http://domain.com/file/file.doc"   ]
I want to remove at the very end [ " ]
so that result will be without "
how to do this.
0
Comment
Question by:theredcode
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
  • +1
9 Comments
 
LVL 14

Expert Comment

by:Vel Eous
ID: 21805930
<?PHP

$target = "http://domain.com/file/file.doc";

?>

<a href="<?PHP echo $target; ?>" title="my link">My Link</a>

<?PHP echo str_replace ( '"', '', 'http://domain.com/file/file.doc"' ); ?>
0
 
LVL 49

Expert Comment

by:Roonaan
ID: 21805947
Where do you have it in? in a variable?

$string = '[ http://domain.com/file/file.doc" ]';

$url = preg_replace('/(^\s*\[\s*)|("\s*\]\s*$)/', '', $string);
0
 

Author Comment

by:theredcode
ID: 21806133
" , i have removed so no wrries..

The thing is i have one variable when i print it using echo it prints as link but i just want text...

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:theredcode
ID: 21806155
i ahve hyperlink in variable,
just want target address not a clickable link...plz help i am stuck with it...
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 500 total points
ID: 21806189
Like this?

$variable = '<a href="link">click me</a>';

$link = preg_match('#href=")[^"]*)"#i', $variable, $m) ? $m[1] : false;

print_r($link);
0
 
LVL 2

Expert Comment

by:loki23
ID: 21806221
odd, are you using some sort of CMS?

if your varible is set using
$myLink =  "http://domain.com/file/file.doc";
then when you use
echo ($myLink);
it should output just as text.

otherwise the only way you SHOULD get a link display is if you used
<a href="<?php echo $myLink; ?>">My Link</a>
or some variation of that

there is no obvious reason that it would intuitively print display the text as a link unless you are using some sort of CMS or development software that has that conversion built in
0
 

Author Comment

by:theredcode
ID: 21806969
Plz visit http://thegurbani.com/audio/index.php

Under [Parent Directory] You will see some hyperlinks
( example.mp3   index2.php   readme_wimpy_button....   wimpy.html   wimpy.php   wimpy_button.swf)

These hyperlinks are dynamically created by a loop. My problem is, my loop outputs them as a link rather than a target address (no link).

In above case, the hyperlink "example.mp3 " points to >> http://thegurbani.com/audio/example.mp3
This is what i need to be printed, just the target text i.e. http://thegurbani.com/audio/example.mp3

I hope this wil given some idea, sorry for my way of putting this like this.
0
 
LVL 2

Expert Comment

by:loki23
ID: 21814339
is it possible to see the loop that creates the output?
0
 

Author Closing Comment

by:theredcode
ID: 31468081
I got idea fromt this comment so plz adjust. I really thank every xpert for his time and efforts...
thnx
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question