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
Solved

i want to get specific string from a sentince

Posted on 2008-10-02
1
238 Views
Last Modified: 2012-05-05
$link="http://fdsafacom/files/1610943/fsadfsdf.rar<br /><b>Password: rdsd</b></div> </div>"
$link1=http://fdsfsdf/files/1610943/fdsff.rar

i want a command that takes this both and only output http://fdsafacom/files/1610943/fsadfsdf.rar
the second one
http://fdsfsdf/files/1610943/fdsff.rar

i have this one but i dose not work
preg_match_all('/(http:\/\/[^\"]+)/i', $page, $links);
it give me in the first link
http://fdsafacom/files/1610943/fsadfsdf.rar<br /><b>Password: rdsd</b></div> </div>"
0
Comment
Question by:mgtm3
1 Comment
 
LVL 15

Accepted Solution

by:
ncoo earned 500 total points
ID: 22625216
You need to add a don't match < like below:
$page="$link=\"http://fdsafacom/files/1610943/fsadfsdf.rar<br /><b>Password: rdsd</b></div> </div>\"
$link1=http://fdsfsdf/files/1610943/fdsff.rar";
preg_match_all('/(http:\/\/[^\"^<]+)/i', $page, $links);
print_r($links);

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Question has a verified solution.

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

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to count occurrences of each item in an array.
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…

861 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