Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 234
  • Last Modified:

How to put hyperlink value in variable?


I have one hyperlink title is "MyLink" which points to ""

I want to store hyperlink value( in variable $target
so that i can simply print the text (not link) >

Also if you can help

i have ["   ]
I want to remove at the very end [ " ]
so that result will be without "
how to do this.
  • 4
  • 2
  • 2
  • +1
1 Solution
Vel EousResearch & Development ManagerCommented:

$target = "";


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

<?PHP echo str_replace ( '"', '', '"' ); ?>
Where do you have it in? in a variable?

$string = '[" ]';

$url = preg_replace('/(^\s*\[\s*)|("\s*\]\s*$)/', '', $string);
theredcodeAuthor Commented:
" , 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...

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

theredcodeAuthor Commented:
i ahve hyperlink in variable,
just want target address not a clickable link...plz help i am stuck with it...
Like this?

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

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

odd, are you using some sort of CMS?

if your varible is set using
$myLink =  "";
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
theredcodeAuthor Commented:
Plz visit

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 >>
This is what i need to be printed, just the target text i.e.

I hope this wil given some idea, sorry for my way of putting this like this.
is it possible to see the loop that creates the output?
theredcodeAuthor Commented:
I got idea fromt this comment so plz adjust. I really thank every xpert for his time and efforts...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now