Finding Text Within A Page
Basically I want to search a page for words and if they are found I want the script to do one thing. If they're not found, I want it to do something else.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
PHP Finding Text
i want to create a PHP Script that would go through a list inside a text file and ignore all of one kind of value and print all of another? e.g. lets say i had a text file that had in it: koum test test test test koum i would want it to go through that text file, ignore all of the test's and only print or echo the koum's.
Finding A Key Word In A Text File
I would like to find a word stored in a text file. Structure: I have one file named keyWords.txt that stores some key words I'm interested in finding. In addition I also have a file named textOrigin.txt in which I store the text to search in. I would like my prog to check if a certain word appears in the text and than to tell me what line it found it in (if it did...). My problem is that the script can't find the words I'm looking for. I took one word from the word list and put it into the text file to be searched, for some reason this word is not found by the prog. I used 'enter' at the end of each line. The word being used is on line 3 in the keyWords.txt file. I have some reason to belive that the reason lie here: if ($pos) { echo " line $i: $storeWord[$n] "; } I also tried it with if (!$pos === FALSE) {...} but nothing there either... the keyWords.txt file: ------------------------------- Recording Site Recording Type INTRA SUA ................
Finding Double Data In Text File
I am working on this e-mail newsletter subscription thing and I am storing the data in a txt file (mySQL is better, I know but I want it to be compatible with non-mysql systems). Off course I don't want any e-mail adresses appearing twice in my list (the list looks like this: someone@somewhere.com, blah@bla.com, et cetera). How can I prevent this?
Finding Links In A Page
I want to parse a html file in order to retrieve all its links and put them in a table. Can someone please help me w/ the better way to do so ?
Finding What Page Wanted To Include
guys say if I include("anyfile.php") into a file. Is it possible for me to access the calling page from anyfile.php. Can I do something like this for instance:: if callingpage == "newauthor.php" then mysql(INSERT into author.....) else mysql(INSERT into content...)
Problem Finding Source For Php Page
We have a page on our site and I have identified what should be the php file on the server that generates it, but when I change the file, the changes are not reflected in my browser (after I refresh).
Finding Out How Long It Took To Render Page?
Does anyone know of a quick and dirty way to find out how long it took to render a page? I'm using PHP4 and MySQL3 and Apache. Is there perhaps some mod_php function, or what?
Getting The Text From A Web Page
I need to take a web page and parse the text from the site. I am thinking of using regex to kill the script and style sections, then strip tags or more regex to kill the reset of the non-text. I need to have the text categorized as sentences, so I some how have to keep track of how it is grouped with other text. I have two questions: 1) What do you guys think is the best way to do this? Regex, explodes, iteration, building a DOM structure, callbacks? 2) What would the regex look like if I wanted to find <, then any number of whitespace chatarers, then the word script, then anything except for (<, possible whitespace, /script, and then anything until >). Put another way, how can I match the style section of a document?
Q: Read Text With VBA From A PHP Web-page
I created a page on our intranet that shows a number and that increases for every time the page is opened. It is similar to a visitors-counter. When I look at the page with Internet Explorer it works just fine. Now I want to read this web-page from a MS-Word macro and include the number as a company wide unique id in my MS-Word document. Unfortunately, the PHP script doesn't update the counter when I call it from my MS-Word macro. How can I force PHP to update my counter when I call it from a VBA macro? I am using the following code:
How To Place Formatted Text On The Php Page
I'm entering data through textarea, and I want to display the same data on the form with all formatting settings. means, if I pressed enter while entering text in the textarea to make a separate line, the separate line has to come when displaying on the form also.
Changing Text On Page Via Dropdown Box.
I have a webpage that draws various text decriptions from a mySql database. The description displayed on the page is controlled via a dropdown box. Currently I am using Javascript with a dropdown box (onChange handler) to change the value of a textbox. Can anybody think of a way that I don't have to use a textbox(with its' scrollbars and background)? How can I change the value of a php variable by changing the selected index of a dropdown box?
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?
Display A Text File On A Web Page
I have a text file that I am trying to display on a web page. If I cat or more the file it formats and displays fine. When it comes up in the browser it seems to loose tabs and the format gets messed up. This is how I display the file. $show = file("./fields/combined/$cdp$store"); $arrayitems = sizeof($show); $x=0; while ($x < $arrayitems) { print("$show[$x] "); $x++; } If I edit the file it has ^M at the end of each line if it matters. Does anyone have a better idea as to how to display it?
Displaying Text While Page Is Loading
i'm trying to display text while a page is loading using a method similar to the following: <? ob_end_flush(); echo 'AAA<br>' flush(); sleep(10); echo 'BBB' ?> in this script, AAA and BBB appear at the same time - when the page has fully loaded - which is not what i want (i want AAA to appear and then 10 seconds later, BBB to appear). pursuant to the suggestions on php.net's entry for flush, i've also tried the following to no avail: <? echo 'AAA<br>' ob_flush(); flush(); sleep(10); echo 'BBB' ?>
Text File Download On .php Page
I have created a website in which I want to put a link to download a text file. When I used simple: <a href="Dir/File.txt">Download file</a> I had such problem that instead of dowloading the file contents was displayed in browser. In some book on PHP5 I found a "solution": create a...
I Want To Create Web Page Acting As Text Editor?
What I am trying to do is to create a tutorial for my beginning students for JavaScript and PHP, using a very simple online editor like the one @ w3schools, So the left window will be the text file code, such as: <html> <body> <script>document.write("This is a test.");</script> </body> </html>...
Paste HTML Page Inside Text Area
i want to create a newsletter or emailer form sender. and that form has a text area. can be an ordinary text area or can also be tinymce. i want to have the text area in such a way that an HTML page can be pasted in the text area (let say the html page is jobpost.html) and send it to the email address that i specified.
How To Populate Data Into Text Fields On Page Load??
I am creating an account management page that shows the user's contact information and I would like to populate the textfields so that the user doesn't have to type in all his information when he wants to change something. I want to have him type in only the information he wants to change or update. I already have the data displayed on the page. But now I would like to take the data and fill in the textfields with it.
Clearing The Input Text Field After Submiting The Form To A New Page
I have a page with a form with an input text field ... and when a user types his/hers ID ... and submits the form - his/hers page opens in a NEW window .... but the value (ID) that was written in the original window remains. I want to make sure that the form input field on the original page becomes "invisible" - by refreshing/reloading the original page or just by clearing the input form after submission. For now I have put in a meta refresh tag in the head of the html file ... but that is not the solution ... becouse I only need a one time refresh/reload of the page ... and this is to happen right after the input text value is being submitted.
How To Change Template Menu Link Text Color For Page Currently Viewed ??
Say you have a left menu that stays the same on every page within in your site. Obviously you would make this menu a template or library item, so that when you edit one version, all the others are updated. Let's say the left menu is the following: Page_1 Page_2 Page_3 Now, when I am viewing Page_1, I want the "Page_1" text in the left menu to be red, so that the viewer knows what page they are on. When I click on the left menu link for "Page_2", then I want the "Page_1" text to go back to black and the "Page_2" text to be red.
Write Text To An "image-page"
If I generate an image, is it possible to write text on the same page then? If it isn't so, there's no special meaning to generate images, who wants to surf on a page that is out of content, right? <? Header("Content-Type: image/gif"); $img = ImageCreate(100, 100); $black = ImageColorAllocate($im, 0, 0, 0); ImageFill($img, 100, 100, $black); ImageGIF($img); ?>
Finding How Many There Are In A Var
how can I find out how many newlines there are in a variable? It's not hard to find out if there is a newline in the var, but I wanna know how many!
Finding Id Value
i am using php and mysql for this. i only want to keep the last 5 entries in the database. so i will add an entry in, which will have an ID value, then i want to delete the id with the lowest value, which in turn will be 6 from the last entry added. so the code will look like this: $oldid = $newid - 6; $deletethis = mysql_query("delete from table where id = $oldid"); is there a simple way to find the value of $newid ?
Finding Out An IP
I've been wondering for some time now, how to get every visitor's IP address and log them. Any ideas?
Finding Referer In PHP
I'm trying to determine the location a user has come from when they access a script of mine (a custom web logging script). I've searched the manual for 'referer' but can't find any relevant references and looking at output from phpinfo doesn't shed any light on which, if any, variables might hold info about where the user has come from.
Finding The Sum In Mysql
What would be the easiet way to add the values of a certain field in every record that it occurs in. For example, If a person is placing multiple orders on a website and each order is to be shipped to a different location. Each seperate order is being stored in the mysql db and I need to add the shipping costs of all orders together when the user is ready to check out.
Finding The Last Occurance
I'm working on a update at my site. Every file on a part of the site means something. I want to accomplish some kind of a directory browseing and at each file displays the realtive info in it. Anyway... The following part of the code is made for finding the last occurance of '/' and after i did it, it looked kind of 'primitive' to me :). Is there any other optimised way of finding the last occurance of a substring in a string ?
Finding MySQL With 5.0.3
I have loaded PHP MySQL and Apache on windows in the past but recently had to reload my Win XP which is SP2 fully updated. Have reloaded Apache - fine - and MySQL and MySQLAdministrator - working fine Loaded PHP 5.0.3 and worked through configuring the ini to show a path to the ext file and so forth - copied some of the dll in the apache file. Copied many of the addtional modules in pecl into the php/ext directory and uncommented lots of them in the php ini (as suggested in a web tutorial - actually I don't NEED all of them yet) Installed PHPMyAdmin and configured that and then tried to connect but only get the error message that "cant find mysql" I tried this twice first with MySQLi and then MySQL set in the PHPMyAdmin configuration. Same result - some advice on a forum to a similar question suggested copying the dll files to the main php directory (just meant moving them up one in fact) and I did but that does not work either phpinfo shows lots of the modules but not MySQL or MySQLi I am rather puzzled - can anyone help this (long winded) problem?
Finding The Php.ini File
Is there another way I can find where the php.ini file is located besides using phpinfo(); The one that shows up in that file is not a valid directory--is not reading from the php.ini where I have it stored because the changes I'm making to the ini file are not reflected when I run code. I can't do anything with session or includes because the I can't get php to read from the ini, or it is reading from another ini file and I don't know how to access it.
DOM Child Finding
Is there any faster/easier way of finding a child node of a certain DOMNode object than doing something like function getChildByTagname($curnode, $name) { foreach($curnode->childNodes as $node) { if($node->nodeName==$name) { return $node; } } } ? it seems fairly slow and cumbersome. i was thinking xpath, but i can hardly imagine that to be a lot faster, with all the DOMXpath object creation and all, though I didn't benchmark.
Finding Directory
would like to know if there is a way to locate a specific directory on your site. I have a script which scans a directory, but it is not always running in the same directory, so the relative path to the scanned directory will be changed. Is there a way to find the location of the directory to be scanned, and build a relative url to it?
Finding H-tags
I am trying to build a script whic will convert html pages, to php, and formatting them to fit the php file's setup... i am trying to also improve navigation - which is where i am stuck. I need to find all information located between any number of <h2> </h2> tags, and place the contents into an array, which i can then print of, and link to that section i just need to find a method to find the information, and then put it into an array.
Finding Out IP Addresses
is it possible to get the persons IP address so that depending on what IP he has come from, I send him to a different page? any ideas?
Finding Pagination
First, let me say this is NOT a "How do I paginate my results?" question. I know how that works. Problem: I have items that are listed by date and medium. Both have paginated listings for searching for items. What I need to do is go back to either list to the page where the current item is listed. Say item #10 is listed on page 1 of dates, and page 5 of mediums [simplified for illustration]. I want the user to be able to come from dates - then move to the mediums listings, while finding the item just viewed on the resulting page. To determine the mediums listing I tried a function where I looped through a pagination function looking for the $id of the item in the result set with in_array(). It would only return the highest page number, if it returned anything. I have really trashed the function, and have to start from scratch. It seems my logic is wrong. Code:
Finding Out About Html_doc()
I'm trying to get some PHP4 code working on PHP5 - and am having an issue with a part of the code that uses html_doc() to turn html text scraped from a website into something that can be processed by DomXml functions like xpath_eval() I've found a nice looking wrapper at http://alexandre.alapetite.net/doc-...mxml-php4-php5/ which seems like it should do PHP4<->PHP5 work, except that it doesnt support html_doc(). I've tried replacing html_doc() with: domxml_open_mem($doc,DOMXML_LOAD_RECOVERING) but I can't get that to work even with the PHP4 - is that down to validation errors in the HTML? My problem is that I can't find any documentation to explain what html_doc() is meant to do and I'm new to the details of domxml coding (though I know what an XPath is...) In summary, two questions: - can I use domxml_open_mem() as a replacement for html_doc() in PHP4/domxml. If so, how? - where can I find documentation on html_doc()? I've googled, searched php.net and looked through group archives and can't find anything
Error Finding
My current web site appears correct. However, I know some browsers are smart enough to get around misplaced tags, and other syntax errors. Does anyone know of a good browser(s) that isn't so forgiving but still supports server-side html (shtml) and php scripting? Also, are there any tools out there that identify syntax errors within html, javascript, php, and or pearl code?
Finding The Mode?
Does anyone know how to write a program to find the mode of a series of numbers? I need to find the mean, median and mode. I was able to find the formula's for the mean and the median. But I have not been able to find a formula to find the mode. I know that the mode will be the numbers that are listed multiple times. I just can not figure out how to write this in the program to echo the mode.
Finding Out IP Address Behind NAT
I am writing a PHP app for a small business (family member owes me after this...) but they need to get their box back before I am finished. They have a DSL with dynamic ip and I need to be able to SSH in to their box, so I need to write a script that i have run as a cron job that will email me the current public IP of their DSL modem...
Finding The Mode
Can't figure out how to find the mode of a file (string occurring most often). Has anyone else managed to do it?
Finding A Value Within A String
Say I have a string, for example: "Name: bob, Age: 22". I know that there is a name stored in there and that it is in that format. How can I trim that string down until it's left with just the name?
|