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 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
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
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
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
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
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
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
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
|