Extract Each Part Of A Page That Are Enclosed In A <b>-tag
I would like to extract each part of a page that are enclosed in a <b>-tag, but ONLY if there are no other tags enclosed.
<b>some text</b> <-- a match
<b>some text <i>in italic </i></b> <-- should NOT match
This is what I have so far:
$pattern = "/<b>(.*?)</b>/si";
preg_match_all($pattern, "<b>some text <i>in italic </i></b>", $out);
Any thoughts?
View Complete Forum Thread with Replies
Related Forum Messages:
Extract Part Of A Record
Hey all. I'm writing a small program that needs to be able to extract the month from a field called "entered" that stores the date and time entered in the following format: December 21st 2006 10:22:04 AM What I need to know is how to extract the month, regardless of which month is selected from a list. I could pass the month to the script as a variable then switch($month) and perform a query using the SUBSTRING extraction method depending on the length of characters that comprise the full spelling of the month. Would this be the best way to go about it and just switch out the queries depending on the month variable?
View Replies !
Substr :: Extract Part Of A String
Say i wanted to extract part of a string with the substr command i need say 1.mickeymouse-home how would i extract just mickeymouse and then extract home after wards $string = 1.mickeymouse-home; substr($string1,strpos($string, "-")+1); - i thought this would get me everything after "-"
View Replies !
Page Loades Part Of The Page
the below code is kinda working but its only loading part of the page, when I do a page refresh the rest of the page loads. the part of the page that is not loading correctly is the bottom 1/2 which displays images. Code:
View Replies !
Caching A Part Of A Page?
I am working on a custom banner generator for some of our users. Its basically a flash banner that can take vars for colors etc, so users can integrate with their sites colour scheme. Its set up currently with the banner at the top as a preview, with e.g. .swf?color1=00000&color2=45efef in the object and embed tags. Below this is a script that is 3 nested for loops, that increment a var each and convert that to hexidecimal. The three hex refs are then concat'd together, and set as a CSS background to a transparent gif with an href around that calls the same page with the new colors in the url, which get passed back to the flash movie. (hope im making sense here :)) So theres about 500 or so (im incrementing the vars by two,otherwise its way sloooow) <a><img></a> that have to be generated on each page load. Im wondering how and if i can speed this up?
View Replies !
Getting Part Of Another HTML Page
I'd like some help with writing a script that grabs part of another HTML page. For example : I want to grab the content of a HTML page that contains the following strings : <!-- begin --> and <!-- end --> Then I want to get all the content (including these two tags) that is in between the two tags.
View Replies !
Refreshing Part Of A Page
Can some one help me if it is possible to refresh a part of a page, without reloading the whole page. Let's say, i want to add a small message box to my webpage. After writing a message, the user presses the send button and i want only this part of the page to refresh and give him a status message saying his message was successfully received.
View Replies !
How To Let Php Reflesh Part Of Page
I want to write some code that when some variable condition is met, it will change a table cell value (only reflesh that value instead of the whole page), I used to think it as calling JavaScript function first, which in turn change that table cell value in the page. But I don't know how to let php call JavaScript, or mimic click button action to call JavaScript.
View Replies !
Selective Rendering Of Part Of A Page
I want to skip the rendering of certain parts of a Web page if the user doesn't have a certain permission (e.g. a cookie). I'd like to do it along these lines: <p>Anybody can see this paragraph.</p> <? start_protected_section($got_permission); ?> <p>Not everybody can see this paragraph.</p> <? end_protected_section(); ?> Is it possible to disable the rendering of a section outside the code like this (perhaps by setting a PHP flag to redirect subsequent output)? I don't really want to complicate things by moving part of the page into a separate "include file" or mixing the HTML and PHP by using a here-document (the <<<END syntax).
View Replies !
Include Specific Part Of Page
i know that the include() function allows you to include a page with php but how do i only include PART of a page like specific tables? what im trying to do is get the certain parts of this page: ...
View Replies !
Need To Copy Text From One Part Of Page To Another
It has been great so far but I hit a road block on one thing and I figured the brilliant minds here could help. This site isn't in a database because its 3000 pages of HTML now and we figured we can do work arounds to make it look right. We are starting a database for future data though Code:
View Replies !
Extract Data From A Web Page?
with PHP, can somebody direct me or give me some insight on how to go about extracting data from a web page. Say I want to pull sports statistics from a page.. how is this done?
View Replies !
Extract Certain Data From Page?
For example if a source had links that were all like http://server.com/dir/file.ext?id=1234567 and I just wanted to extract all of the the numbers after the id= how would I do it? There would be a lot of different links with different id's and I'd like to extract all of them.
View Replies !
Extract URLs From A Web Page
I am setting up a trusted feed for Ink and the third-party provider seems to be having a bit of a problem getting the full list of my URLs extracted. I have a complete site map for this site, which is broken down into 13 pages, each with 100 or fewer URLs. I would like to use some sort of script to pull the URLs and put them in a big list in Excel or Notepad. Is there an easy way to do this? I posted this in PHP because I understand it well; if there is another language that does it better.
View Replies !
Change Part Of A Web Page After X Seconds Delay?
I was asking about how to pass a new array number with a page refresh and someone responded: But what I don't understand is why you want to change images like that on page reload, I have never seen it before. That raised the question to me - if I have written out a web page in PHP that has an image displayed on the page - is there a way to have it change the image every 10 seconds? Could you do this with a For Each or While type loop? I thought once the script was parsed it then wrote the page source and it doesn't change on the screen.
View Replies !
Extract Only Plain Text From A Page
Basically, what I am trying to do is write some PHP code that will automatically take text from any web page and eliminate all the HTML, CSS, and JS codes and formatting, leaving only the plain text from the page. I got my code started, but I have hit a snag with javascript and css codes. This is what I have so far: <?php $geturl = $_GET["url"]; ob_start(); include($geturl); $page = ob_get_contents(); ob_end_clean(); $output = ereg_replace('<script.*.</script>', ' ', $page); $output2 = ereg_replace('<style.*.</style>', ' ', $output); $plaintext = strip_tags($output2); echo $plaintext; ?> The strip_tags function automatically removes all html tags, but it doesn't do anything to javascript and css because html code is not provided between the beginning and end tags, whereas javascript and css codes are both contained within two separate tags, like this for more clarification: html: <div name="htmltag">Keep this text here</div> javascript: <script>function somejs() {remove all this code}</script> As you can see, the text between the div tags should stay, but the js between the script tags should be removed because it is code. I then tried the ereg_replace function to get rid of js and css codes, but there is a problem when there is more than 1 piece of js or css code. The wildcard value (.*.) skips over any ending script or style tags until it reaches the last ending tag, therefore deleting all the text between the two pieces of code. Example: <SCRIPT>function somejs() {remove all this code}</script> //removes all text and code from beginning here KEEP ALL THIS TEXT HERE <script>function somejs() {remove all this code}</SCRIPT> //to end here Now finally down to the question, is there any way to only remove the js and css code between the beginning tag and the immediate next ending tag? Or is there any other way to get rid of the javascript and css codes?
View Replies !
Extract Specific Parts Of A Page
I have a js script that runs from a remote location, it displays the latest lottery results, but there are ad's on it, i would like to extract the gif/jpegs from it, can it be done and if it can how??
View Replies !
Extract The TITLE Section Of A Web Page Using Preg_replace()
I went through some examples, tried a bunch of things. but still can't figure out why I can't extract the TITLE section of a web page using preg_replace(): <?php $response = file_get_contents($url); $output=preg_replace("|<title>(.+?)</title>|smiU", "TITLE=$1", $response); $fp = fopen ("output.html", "w"); fputs ($fp,$output); fclose($fp); -----------
View Replies !
Regalar Expression To Extract An Html Link From A Page
I have a regalar expression to extract an html link from a page: href=(["']?)([^>1]*.html)1(?: [^>]*)?> It looks after the "href" for an optional quote and then looks for something that is not the quote or the endarrow. The problematic part is [^>1]*. It should exclude anything with the quote, but somehow that doesn't work. Maybe 1 is not allowed inside brackets? I would like some advice on how to handle this.
View Replies !
Getting Part Of A String
What I am attempting is to retrive part of a string, the string comes from TEXT field in mysql db using mysql_fetch_row. It is an article, in the article there is flags like for example [image]img=34,align=left[/image]. Now I would like to retrive the [image]img=%[/image] part to be able to use the wildcarded number for a database query to get the image link and image comment then giving it all a proper html formatting. After that, I replace [image]img=%[/image] in the original string with the newly formatted html.
View Replies !
Extracting Part Of Specified URL
I have seen some tutorials on how to retrieve a section of the current URL with php, but what I am trying to do is a little different. I need to be able to specify any myspace URL in a form and have the output be a section of that URL. For example: I input the following URL into a form field: http://www.myspace.com/index.cfm?fuseaction=user.viewprofile&friendid=257367900 when the submit button is pressed the output should show: 257367900 I need it to be so that I can input any myspace url as such and the output will be everything after the "&friendid="
View Replies !
Get The Last Part Of An Array
I am trying to preselect all the checkboxes on an edit form if they are part of the record in the database I put this to get an array of categories that pertain to that record being edited. Code:
View Replies !
Selecting Part Of A Value
Learning php and mysql, and frankly it's making my head spin... Anyway, how would you get a result and output only part of it? Like get "2004" and only output "04". It's probably a stupid question, but I can't seem to find the correct syntax in any of the manuals. Specifically, I want to output the standard mysql "0000-00-00" date format as "mm/dd/yy". I know there are scripts out there for dates, but I don't want to do anything fancy with it, just switch some numbers around and output part of a result (plus I'm trying to learn this stuff, and this seems like a question that will provide answers for other things as well). An example script would help me alot. From what I know so far, I think the answer would be to select the field, explode the string, then assign and output the variables with "/" in between.
View Replies !
Get Part Of A String
if I could use php and get certain parts of a string like $string: = "<table><tr><td>Name</td><td>Desithugg</td></tr></table>"; Would it be possiable to use something like preg match to get only that part Desithugg into another string like $name. So I want to get the part between <td>Name</td><td> and </td></tr>. If it's possiable can anyone give me an example. I tried looking at the manual but didn't quite get it.
View Replies !
Get Part Of A Integer
just like you have substr() to get part of a string, is there a way to get part of an integer? $myVar = 20060103142005; // and want $myVar = 20060103; what's the best way to do it? $myVar = 20060103142005; $myVar = substr ($myVar, 0, 8); echo $myVar; doesn't work. Trying to convert the number to a string doesn't work either: Code:
View Replies !
Part Of A Script
Apparently there is a problem with part of a script, this is the problem part: Code: $member['reputation'] = $this->html->reputation_level( $member['id'], rtrim($member['rep']) );
View Replies !
Update Part Of A Row
if it's possible to update part of a row in phpmyadmin? I know how to do it with a PHP script but phpmyadmin would be better in this case. Example: The value of the row is BBB001, I want it to be ABB001. It's only the first character of the row I want to update.
View Replies !
Last Part Of IP Address
For example if IP address is 64.12.34.56, I want to display it like 64.12.34.** Here is my code: $this_ip="64.12.34.56"; $this_sub_ip=substr($this_ip, 0, strrpos($this_ip, ".")+1); $this_sub_ip_replace_length=strlen($this_ip)-strlen($this_sub_ip); for ($index=0; $index<$this_sub_ip_replace_length; $index++) { $this_sub_ip=$this_sub_ip."*"; } echo ($this_sub_id);
View Replies !
Get PART Of A File (via ID)
So I want to get part of a file, specifically everything WITHIN the div id="left". I have this code, but it gets the whole file. I want to use this to edit a remote file test.html). Code:
View Replies !
Using Only Part Of A String
Pulling data from old DB to new DB. One field is text for an article, I need to pull it and only get part of it for a new summary field. How can I get just part, say 1 or 2 paragraphs out of the string?
View Replies !
Part Of WEBPAGE
This is my first time in the forum and right on the start i need help of you guys. I am a new developer and I am trying to build a page in PHP/Html. what I want to do is refresh only a part of page. User fills in the form and comes toward the end of the form where he decides how many pictures to upload and the momment he selects number of files to be uploaded from a pop up menu the bottom part of page should get refreshed having that many number of file input fields as many were selected by the user.
View Replies !
Display Part
Im using $date('Y-m-d H:i:s') to grab date and store it in a database in datetime format, but on some occasions Id prefer to display just Y-m-d or Y-m-d, 2pm as apposed to the full date n time values. Is there any simple way to split the data in the row so I can just grab the first part of it like this.
View Replies !
Replacing Part Of A String
I am using the command ereg_replace() to replace " with ' . For fast web pages, I use Microsoft Frontpage and it has everything use ". I have to change them all to use ' . The code is writen and it works, sort of. It has some text displayed at the end I don't want. Here is the my code:
View Replies !
Replace Part Of Line
ok so i have a text file thats has a word then a definition i want to replace everytihing after the first word file.txt : Gadbee (n.) The gadfly. Gadder (n.) One who roves about idly, a rambling gossip. Gadding (a. & n.) Going about much, needlessly or without purpose. Gaddingly (adv.) In a roving, idle manner. ---- so for "Gadbee (n.) The gadfly." i want to keep Gadbee but replace the rest of the line with nothing ("") heres what i got but it doesnt work: Code: <?php $file = $_GET['l']; $fp = file($file); $num_lines = count ($fp); $n= $num_lines; $i=0; echo "<pre>"; while($i < $n){ $r= ereg_replace(" $"," ", $fp[$i]); //the line that need to be changed echo "$r"; $i++; } ?>
View Replies !
How To Echo Only Part Of A Field?
I set up a news-type publishing system but I'm running into one problem. I need to echo part of the "body" of the news article for the front page of the site to act as a teaser. For instance, I just want to echo the first 255 characters. Is there a function that I can use to suck out just the first 255 characters of a field?
View Replies !
Mime Part Numbering
IMAP_FETCHBODY requires the "part number" to fetch. how the part numbers are derrived. for example, here is the formatted parts array from a message: Parts: array(2) { [0]=object(stdClass)(12) { ["type"]=int(0) ["encoding"]=int(0) ["ifsubtype"]=int(1) ["subtype"]=string(5) "PLAIN" ["ifdescription"]=int(0) ["ifid"]=int(0) ["lines"]=int(1) ["bytes"]=int(38) ["ifdisposition"]=int(0) ["ifdparameters"]=int(0) ["ifparameters"]=int(1) ["parameters"]=array(2) { [0]=object(stdClass)(2) { ["attribute"]=string(7) "CHARSET" ["value"]=string(10) "ISO-8859-1" } [1]=object(stdClass)(2) { ["attribute"]=string(6) "FORMAT" ["value"]=string(6) "flowed" } } } [1]=object(stdClass)(15) { ["type"]=int(2) ["encoding"]=int(0) ["ifsubtype"]=int(1) ["subtype"]=string(6) "RFC822" ["ifdescription"]=int(0) ["ifid"]=int(0) ["lines"]=int(34) ["bytes"]=int(1609) ["ifdisposition"]=int(1) ["disposition"]=string(6) "INLINE" ["ifdparameters"]=int(1) ["dparameters"]=array(1) { [0]=object(stdClass)(2) { ["attribute"]=string(8) "FILENAME" ["value"]=string(21) "TEST OF HTML MAIL.eml" } } ["ifparameters"]=int(1) ["parameters"]=array(1) { [0]=object(stdClass)(2) { ["attribute"]=string(4) "NAME" ["value"]=string(21) "TEST OF HTML MAIL.eml" } } ["parts"]=array(1) { [0]=object(stdClass)(12) { ["type"]=int(0) ["encoding"]=int(0) ["ifsubtype"]=int(1) ["subtype"]=string(5) "PLAIN" ["ifdescription"]=int(0) ["ifid"]=int(0) ["lines"]=int(10) ["bytes"]=int(251) ["ifdisposition"]=int(0) ["ifdparameters"]=int(0) ["ifparameters"]=int(1) ["parameters"]=array(2) { [0]== object(stdClass)(2) { ["attribute"]= string(7) "CHARSET" ["value"]= string(10) "ISO-8859-1" } [1]= object(stdClass)(2) { ["attribute"]= string(6) "FORMAT" ["value"]= string(6) "flowed" } } } } } } ["value"]=> string(6) "flowed" } } } } } }
View Replies !
E-Commerce Merchants (part 2)
One consideration in designing a web interface to a payment system is the ability to switch e-commerce providers seamlessly. Has anyone looked into "isolating" the ecommerce part of a web site so that you could change banks or merchant accounts without disrupting your users? What comes to mind for me is a period of overlap, so fulfillment and chargeback is given time to expire on the old merchant. Also, the need to "skin" the store so site users see a consistent look and feel through as much of the process as possible. Any other thoughts? Know of any good tutorials?
View Replies !
PHP Configuration Problems Part II
PHP starts beautifully now. But MySQL is another story. When I restart Apache I get the following error message, which I copied from the Apache error log: [Tue Oct 11 21:35:17 2005] [notice] jrApache[init] JRun 4.0 (Build 91015) Apache 2 module - Jan 6 2005 15:25:33 PHP Warning: PHP Startup: Unable to load dynamic library 'c:/php/ext/php_mysql.dll' - The specified module could not be found. in Unknown on line 0 My path is set as follows in php.ini: extension_dir = "c:/php/ext/" I also tried it with and without quotes and without the last / to no avail. And php_mysql.dll does live in this directory. The original path was "./", which worked just as well.
View Replies !
|