Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP






SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





Find A Html Tag In String


$string=' this is image 1 <img src="www.abc.com/abc.gif"'> and second is <img src="www.df.com/edfg.jpg">;
function getAttribs($t, $a, $s) {
preg_match_all("/(<".$t." .*?".$a.".*?=.*?")(.*?)(".*?>)/", $s, $m);
return $m[2];
}
$arr=getAttribs('img', 'src', $string);

Here i get all the src of <img> tag.




View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
Find String In String In File With Repeating Data
I have files with the following data:

*******************
SEQ: [+1]
DTM: [203:20050914:102]
FII: [OR+05407059214]

SEQ: [+2]
DTM: [203:20050915:102]
FII: [OR+05407059999]

SEQ: [+3]
DTM: [203:20050813:102]
FII: [OR+05407099999]

and so on....
*******************

The file could have 1 or 100 sections and I recieve them every day. Code:

View Replies !   View Related
Find And Cut String
I'm new to PHP, so please bear with me! =)

Is there a nice little function to find a string between to html-tags?
I.e. let's say I have a string with the following text:
"Hello world, <b>this is a test</b>"
I would like to cut out the text between the <b> and </b> ("this is a test").

View Replies !   View Related
Find String
Surely there's a function for this. But I can't find it. I need to search for a string. plenty of those of all flavors,and when I find it I need to capture the following x characters.

Examples:

search the string for 'user=' I don't know who the user will be but it's a 8 digit name/number that follows. I need to capture the info that follows.

other examples..
module=
name ( )

View Replies !   View Related
Find A String
I'm setting up a database search and want to be able to find strings that are part of an array value. For example, if my database has "cats, dogs, goats" and someone uses "cat" as the search query, I want "cats" to be found in the array. I know you can use in_array for EXACT matches but is there a way to find LIKE-type matches in values in an array?

View Replies !   View Related
Find Last Occurrence Of A String In Php 4
Can any body tell how i can trap last occurance of a string in a string. I use strripos()function to do this. But it is available in php 5 ont in 4. And there is php4 installed on my web server. So my scriptting is not running properly. Can any body tell substitute of this function in php4.

View Replies !   View Related
How To Find Several Strings Within A String
I'm trying to find several keyowrds out of string of text which are the list of keywords for a text file. The keyword list is in a field called keywords in a mysql database.
So if the user types in "foo bar foobar" to be looked up and the field contians "Bar foobar foo oyster moregarbage stuff" it will be able to bring up that record.

View Replies !   View Related
Find One String Inside Another
How can I find one string inside another. i'm looking to do something like:

if str("my sentence here", "sent") {
do something }

View Replies !   View Related
String Find And Replace?
What would be the easiest way to check if a string has a certain text in it. If it does not, add it, but if it does, do nothing. I don't want it to be case sensitive either. Code:

View Replies !   View Related
Find A String In Array
i have this array:

$str = array("apple is red", "banana is yellow", "pineaple is tropical fruit", "coconut is also tropical fruit", "grape is violet");

i want to find string "coconut" inside $str and put the whole string "coconut is also tropical fruit" into variable $coconut. Code:

View Replies !   View Related
In A String Find Out If It Contains A Mailadress
For a given string, I need to find out if it contains a mailadress, and if it does I need to replace it with soemthing else. I tryed using preg_match and preg_replace but can't get it to work. Does anyone have a clue?

View Replies !   View Related
Find The Length Of The String
I want to find the length of the string.That i did by using strlen().now i want to put it in an array .

View Replies !   View Related
Find Part Of A String
I am an ASP guy who has been converting to PHP. Anyway, I'm having a problem figuring out how to find part of a string.

What I am trying to do is to list any file that starts with "info". So I've got a while loop that will show all the files, but now I'm trying to figure out how to display only the files that start with "info". In ASP it would be like this:

If Left(strFileName, 4) = "info" Then
Response.Write(strFileName & "<br>")
End If

Does PHP have a function like this? In the example above it reads the first "4" characters in the string strFileName and compairs it to "info".

View Replies !   View Related
Use Ereg To Find Two Different Words In A String?
Can you use ereg to find two different words in a string (I'm trying to look for AND and OR) and then do two more ereg's to look for those same words but seperately.

View Replies !   View Related
Find Out If A String Contains Only Letters And Numbers
i'm pretty new to the preg_match() function and what im simply trying to do it find out if a string contains only letters and numbers, nothing else!  Here is what i have so far, tough it does not work:

if (preg_match('/^[a-zA-Z0-9]+$/', $catagory))
{
  //OK
}
else
{
  // NOT OK
}

View Replies !   View Related
Preg_match Find All Instances In A String
Im having trouble with preg_match_all. Im trying to make preg find all instances of test in a string, and then print out how many it found with a for loop. The problem is that only three test's are printet out. There are six in total. Below is the script :

<?

$text1 = "Test 1, test 2, test 3, test 4, test 5, test 6";
for ($t=0; $t<count($text1); $t++) {
  preg_match_all("/test/i", $text1, $match1);
  print "<br>".$match1[0][$t];
}
echo "<hr>";

?>

What am I doing wrong ?

View Replies !   View Related
Find Data Between 2 Characters In A String?
I want to find and display data found between two characters in a string.

Example>

Form sends the following to the .php page....

$data1 = "The Domain Name [somedomain.com] has been renewed";

I want to be able to pull out and display only "somedomain.com".

Example, I want a variable called $domain to only hold the domain name itself, without the brackets or the text.

somedomain.com

I have investigated function strstr().

$data1 = "The Domain [somedomain.com] has been renewed";
$domain = strstr($data1, '[');

OUTPUTS:
[somedomain.com] has been renewed

I can then use substr() to remove the first "[".

$domain = substr("$domain", 1);

OUTPUTS
somedomain.com] has been renewed

But, I am stuck, conceptually, with what to do to trim the end after .com . Note, somedomain.com will change. One run, it could be somedomain.com and the next, it could be "somethingelseentirely.com". Thus, the character length of that part of the string will change each time.

View Replies !   View Related
Preg_match() Help How To Find Two Words In A String
I am just now diving into learning use regular expression and my head is spinning with all the articles I have been reading. I think what is must confusing is all the symbols that are used when creating a regular expression.

I have a database that has a field I entered some keywords. Now Im querying the database to search the keywords for words I passed through a link. Code:

View Replies !   View Related
Find URL And Replace With HTML Hyperlink
I have a database full of user input, some users enter in URLs.. when I display this information, I would like to go through the text, look for URLs and turn those into real hyperlinks... so I need to take http://www.whatever.com and make it a real hyperlink.

Am I in the right place? If so, how would I go about doing this?

I am using php/mysql and I would like to simply wrap a function around, for instance, my $output variable which holds the data retrieved from a user input.

View Replies !   View Related
Find And Replace Query Variable In URI String
I am trying to find and replace the query variable relating to the session id "sid=". This is the portion of the script that has to find out where the sid= is in the string and replace it with an updated version that contains the session id. It is not finding "?s=" nor "&s=" when I run it any of the following urls.

http://www.mysite.com/?func=home&sid=
http://www.mysite.com/index.php?func=home&sid=
http://www.mysite.com/?sid=&func=home
http://www.mysite.com/index.php?sid=&func=home

I commented out the parts which do not have a bearing on the basic string search function.
PHP Code:

View Replies !   View Related
Function To Find 6 Digit Numeric String
I need to parse a string and attempt to find a substring in the string that contains 6 numeric digits. the first and last digit may or may not be preceded by a space.

I need to find the starting the ending positions of the 6 numeric digits to that I can extract the string and build an href containing the string and replace those 6 digits with a hyperlink.

View Replies !   View Related
How To List/find Html Tags In Text
What I try to do is to search a text for html tags.

Why. Because I want to use nl2br on the text, but since this command add
br instead of all /n it is not a nice thing to add t.x. a html list inside
the text. Of course it is possible to add the list and remove all space
between li tags, but this is not so readable to the writer.

What I try to do is also to add nl only in the plain text and inside li
and td tags. So in the li case I have to find <ul> and </ul> and <table>..

View Replies !   View Related
IIS Could Not Find .php File, However It Finds Html Files In The Same Dir
IIS could not find .php file, however it finds html files in the same
dir.....

http://localhost/test => the default.htm will be hit, no error

http://localhost/test/test.php => 404 error not found( it exists in the
dir)

The security is set ok, something wrong with the php runtime??
Strange because my application on localhost/prog works smooth.........

View Replies !   View Related
Find And Replace Text In An Html File
I need to be able to change a word to another word in an html file. So every time "word" is found in the html file it needs to be changed to a value that is stored in a mysql db.

View Replies !   View Related
Using Preg_match To Find Values Of Html Tags
Is this a good way to retrieve the title and description from the tags of an html page? Code:

View Replies !   View Related
Ereg And Preg Versions To Find If Any String Is Enclosed In Quotes
How do I write the ereg and preg versions to find if any string is enclosed in quotes??

"real estate" -> match
real estate -> no match

View Replies !   View Related
Use Preg_match To Find Out If A String Begins With Either "http"
I try to use preg_match to find out if a string begins with either "http",
"/somethime" or "../something". In my php script I have the following line:

if (0 == preg_match("/^(http.+)|(/[a-z].+/)|(..[a-z]+)/i",$string)

But I get a:

Warning: Unknown modifier ')' in myscript.php at line nn

What's wrong with the pattern?

View Replies !   View Related
Html Tag In A String
I am trying to be able to take off all HTML tag in a String before display it on the screen. Is there a effective way to do it.

View Replies !   View Related
Preg_replace With "[g]" As The String To Find
I'm having rpobs with this because my string pattern to find is "[g]" and when i use the following code :

$str = "this is the text to make [g]bold[/g]";
$str = preg_replace('[g]', '<span class="bold">', $str);
echo '<br>'.$str;

it just outputs this :

this is the text to make []bold[/]

so the problem is obviously the square brackets which seem to have some specific meaning in the regular expression. So i tried escaping the brackets with backslashes but that doesn't work - it just outputs this error:

Warning: Delimiter must not be alphanumeric or backslash in

could someone tell me what i need to do to be able to search for "[g]" and "[/g]" ?

View Replies !   View Related
< ? Php $string ? > Within Html Statements?
I'm trying to reduce my code in html by calling a page.php file which blocks out the html for me. I was having a hell of a time since my html wouldn't parse the php code so in page.php I ended and started php and used regular html in between.

my problem is that I'm trying to use a string to lable my blocks of html (you know .... a links menu < home > < go here > < go there > with the $ string lableling each header area. Everything is parsing except for the $ string name --- so I have lots of nested tables with everything filling except the title of the block, Code:

View Replies !   View Related
Having A HTML + PHP String Evaluated...
Does any knows if there is some way to have a HTML string with some PHP code included evaluated?

View Replies !   View Related
Remove A Html Tag In A $string
I am parsing a rss. While parsing i am getting some  images inside the description. Actually i dont want it. so i try to remove <img tags.

$desc = "this is the sample image <img src='image.jpg'> have a look on it";

I need $desc like "this is the sample image <!-- <image src='image.jpg'> --> have a look on it" any help?

View Replies !   View Related
HTML-type String
I'm trying to figure out how to take something like this: Code:

<TAG name="something" title="first">

And extract the information using Regular Expressions so it is put into a multidimensional array like this: Code:

TAG
|--- name -> something
|--- title -> first

Is it possible to do this with one of the PHP preg_* functions?

View Replies !   View Related
Replace String Within HTML
We parse our HTML as PHP. All pages within the site are with “.html” extension. We would like to apply additional variable to all internal links within each page. Instead of maintaining manually, we would like to have a script that would automatically: Code:

View Replies !   View Related
Html Formatted String To Attachment
I working on an email form that takes user's input converts it into a html formatted page and emails this page as an attachment.

I am looking into several mime email classes for php that support this feature.

One thing I'm not clear about is whether attachments can be created on the fly or must they be a file on the server before they can be "attached" to the email.

for example, can I create an html string stored in a variable and make that string become the attached file for the message?

or do I have to first write the html string into a file on the server then create the email header to retreive that file from the server and send it to the user, then go back and delete the temp file?

View Replies !   View Related
Mail Html String Longer Than 255
I've got this script that I found on the Internet with which I want to send an email with HTML in it. So I make a string in which I put all my HTML, but that is longer than 255.

Is there a blob or something else that I can use ?
I need it really bad.

View Replies !   View Related
Function That Transform A String Into Html
I'd like to know whether there's a php function that transform a string into
html... espacially turning
to <br> etc.
I couldn't find it in the php doc.

View Replies !   View Related
Php File As String Generated To Html
I have a page going on a local server but the pages are going to be hosted on another server, which doesn't support php and MySQL. So basicly have to generate the php files into html files. The pages on the localserver are all based on a template page Main.php?Cat=Home

So this is what I'm trying to do. either...open the php template pages in another file then write them as html or...export the php template as html when viewed.So far all I got to see is resource id # 1 Just a little push on the file handling as a string would be much appriciated.

View Replies !   View Related
Check Whether A String Contains HTML Elements
I want to check whether a string contains HTML elements. Is there is any function to check whether a string contains HTML elements.

View Replies !   View Related
Decode Html Input String
Probably not the correct words in the subject but I'll try to explain. I have software in c++ that sends data to a php file on my website. I have all the connections in place since it echoes back an ok to my code. Problem is the data portion is not being read by the php. I dont know how to reference it. Code:

View Replies !   View Related
Removing HTML Tags From String
I have a bit of code that selects data from a MySQL LONGTEXT field. The data will typically contain some HTML tags.

The PHP then cuts this down to 100 characters, and adds ".....[more]" as a clickable link at the end which loads a new page containing the complete data.

If you like, this will produce a list of snippets of ALL entries in the table and the user can choose which one to read in its entirity.

It works brilliantly, but if there are any HTML tags around the 100 character position then random results occur. Well, not random but difficult to calculate.

My solution is to strip out these HTML tags using a PHP function, and then cutting the data down to 100 chars. Code:

View Replies !   View Related
Grabbing Html Tags Out Of String
I have a string that contains text and html. Basically, I would like to grab the HTML tags from the string and wrap some comment tags around it.

Does anyone know how I would do this? I was thinking about using the str_replace function, but this won't work for certain html tags, such as <A href=#"> since the "#" won't be known beforehand. Maybe a simple regular expression?

View Replies !   View Related
Detect HTML Tags In The String
I need to know if a given string contains HTML tags or not. Is there a way to detect HTML tags in the string?

View Replies !   View Related
How Do You Remove Html Tags From A String?
Is there a function to remove html tags from a string?

View Replies !   View Related
Converting The Posted String To The Value Of Html Element
I've been very confused in dealing with posted strings. For example, if I fill in a text element with "(double quote), submit it and display it in a text and a textarea, I get "(backslash followed by double quote) in the textarea element but (backslash only) in the text element.

Code:
<input name="somename" value="<?php if(isset($HTTP_POST_VARS['submitName'])) echo $HTTP_POST_VARS['somename']; ?>" />

I made a function which correct the misbehavings:

View Replies !   View Related
PHP String Concatination With Html Select Combo Box
I have problem in PHP String concatination with html select combo
box.

There are 3 files

addressbook.sql :
concat1.php
concat2.php

In concat1.php , if we select User Name in combo box & give input as 3
in
text box.
It display following output
subhash kanade,3 sk@yahoo.com

But, it is not display in that way.
So, please see that code & tell me correction.

addressbook.sql

-- Table structure for table `addressbook`
--

CREATE TABLE `addressbook` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) NOT NULL,
`email` varchar(50) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ;

--
-- Dumping data for table `addressbook`
--

INSERT INTO `addressbook` (`id`, `name`, `email`) VALUES (1, 'pramod
kumar', 'pk@hotmail.com'),
(2, 'vinod wagh', 'vinod@rediff.com'),
(3, 'subhash kanade', 'sk@yahoo.com'),
(4, 'ketan patil', 'kp@hotmail.com');

concat1.php

<?php

mysql_connect("localhost","root")or die("Database Failed");
mysql_select_db("pradeep")or die("Failed to Connect Database");

$arr=array("concat(concat(name,','),id)","email");

$str="select ".$arr[0].", ".$arr[1]." from addressbook";

$res=mysql_query($str) or die("resultset error");

echo "<table><tr><th>User</th><th>Email</th></tr>";
while($row=mysql_fetch_array($res)){
echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td></tr>";
}

View Replies !   View Related
Regular Expression To Get A Page's HTML Into A String
First wanted to say that PHPBuilder seems like an amazing site to me so far. Until a couple weeks ago I had no idea what PHP was. I recently bought a book and have already learned a decent amount, and am excited by how much PHP has to offer. Anyway, here's my question:

I want to get a page's HTML into a string, and then parse the string and return the first expression in standard US dollar form... $(one or more digits).(2 digits)

How do I go about doing this with, let's say, this page? That is just an example, it doesn't have to be Amazon.

View Replies !   View Related
Improve String Catching Of Html Page
I scripted a prog that extract a string from an html page excluding
all the tags.
The problem is that it works quite slowly and I wanted to know if
somebody of us as an idea how to improve his performance.

CODE

$start="start_str"; //begin string
$end="end_str"; //end string
if($snoopy->fetch("http://www.informative.page.com";)) //get the html
code
{

$string=$snoopy->results; //assign to $string all the html string

- Hide quoted text -
$i=1;
$line = explode("
", $string); //trim the html in lines

while ($i<300)
{
//take only the middle
if ($i>230) {
//explode the line to control the content
$piece = explode(" ", $line[$i]);

$k=0;
while ($k<200) {

//if it content the string that i'm searching... :)
if ($piece[$k] == "interesting_part") {

$word=preg_split("/[s<>]+/", $line[$i]); //to eliminate html tags

$j=1;
$flag=0; //to say when print the word

//extract the string without html
while ($word[$j]) {

if ($word[$j] == $begin) $flag = 1;
if ($word[$j] == $stop) $flag = 0;
if ($flag) echo "$word[$j] ";
$j++;
}

}
$k++;
}
}
$i++;
}
}

View Replies !   View Related
Parsing String Of HTML Attributes Into Key/value Pairs?
I'm working on a project that requires a certain "parsing" functionality... Before I set down to coding this myself, I thought I'd ask in the community if anyone already has available a PHP function or routine that can parse a string of HTML-style attributes into key/value pairs?

For example, an input string (attribute list) might be something like this, as would be applied to an INPUT tag: type="text" name=firstname size=10 maxlength="20"

And the returned result of parsing this string would be something similar to the following array: PHP Code:

View Replies !   View Related
Parse String For Urls, But Not Html Links
I've got this function to convert any urls into the proper links for my CMS. However, if I want to put in my own link <a href="http://www.domain.com">A link to domain.com</a> (rather than the basic url www.domain.com), this function really stuff's it up. Code:

View Replies !   View Related
Problem Pulling String From Html Form
I made a simple "contact" form for my website. However in place of field names, I'm using strings that contain 12-character randomly generated names. The names re-generate each time the form is accessed. Code:

View Replies !   View Related
Eregi_replace Change A Body Tag From A String Of Html
I'm trying to change a body tag from a string of html from whatever it is to <body>. I tried:

$dataHtml = eregi_replace("'<body[^>]*?>',","<body>",$dataHtml);.

View Replies !   View Related
Is There A Way To Take An Html String And Render It As A Web Browser Would, From The Command Line?
I'd like to write a PHP script to be used from the command line on a
Unix machine. I'd like for the script to put together a string, turn it
into a web page, print it, then return control the command line.

Obviously it is quite easy to make a string that is valid HTML and send
it to the printer. The tough part is making look like a web page. In
particular, image tags should print out as images, not image tags.

View Replies !   View Related

Copyright 2005-08 www.BigResource.com, All rights reserved