PHP - Find String In Website/webpage
Hi All,
I'm new at php and I need your help. I'm trying to find a string in a website. I want my website to get a string on another website(I have full access) without really opening it on a browser. For example the string is "MyID=123456", i want to find "MyID=123456"(the MyID number is random and always changing but always 6 random numbers) on another website and output only "123456" on my website. Is this possible? Please help. Thanks Similar TutorialsOk... I had typed this post out ONCE already and when I clicked REFRESH IMAGE to get a diff captcha it ERASED MY POST LMAO this is not my night.... What I need help with is probably more simple then I can even think right now - ive been digging at this for 3 hrs now and im out of time for the night I have a DB Record storing ID's between PIPES | when the initial entry is made in DB it stores it like so |47| NOTE: the number could be different these are ID's number doesnt matter its just between Pipes When the second entry is added its added like so |47||67| say we have a total of 5 Entries |47||67||82||55||69| I need to find ID 82 in that string and it has to be between Pipes Find 82 in data between | and return that ID 82 I am putting between pipes because the ID's can be duplicate digits in different lengths so say I have 8 as my ID and down the string i have another id as 88 -- I cant possibly find the correct ID without some sort of seperation character so i used Pipes soo my end goal is the ability to search and if true or false do action if ($result == $find_id){ echo "ID is there"; }else{ echo "NOT THERE -- Adding it"; } Any help is appreciated guys Thanks SangrelX I just managed to login to a forum using curl, but then I found out I had to extract the session id before I could start posting. The session id is in a string like this: sesc=b97b74351fde8dfbac7391af1f054de9 How do I extract the value b97b74351fde8dfbac7391af1f054de9 if I know that it comes righ behind "sesc=". I think I am supposed to use strpos, but I don't know. I have the following variable: $text = "javascript:openimage('http://images.icecat.biz/img/norm/high/5966342-254.jpg',850,850)" Now I want to put the string "http://images.icecat.biz/img/norm/high/5966342-254.jpg" into a variable called $url ( $url = "http://images.icecat.biz/img/norm/high/5966342-254.jpg" ) How do I do this? I need to find first digit (any number 0 - 9) in a string. I thing I should be able to use: $NumberPosition = strpos($Source, "/[0-9]/", $NumberPosition+1); but it does not work, wonder what I am doing wrong? How can I check this string to see if it has a ~ character using php? Code: [Select] $string = 'userlocation~credentials~specialties'; I am making a online Bible with search function. I was able to do the boolean search for text keywords without much trouble. Now I want a user to be able to type in an exact verse into search form and have that verse display in results. IE: User types in John 3:16 and search result displays that verse. The following works if the user types John:3:16. I cannot figure out how to do this without requiring the user to type a : after book name. Code: [Select] if($search_type=='verse'){ $query2 = explode(":", $query); $bookquery = $query2[0]; $chapterquery = $query2[1]; $versequery = $query2[2]; $result4 = $db->sql_query("select * FROM Bible$version WHERE book = '$bookquery' AND chapter= '$chapterquery' AND verse ='$versequery'"); while ($row = $db->sql_fetchrow($result4)) { $book = $row['book']; $chapter = $row['chapter']; $verse = $row['verse']; $scripture = $row['scripture']; echo "<b><a href=\"modules.php?name=Bible&call=chapter&viewbook=$book&viewchapter=$chapter&version=$version\">$book</a> $chapter:$verse</b>"; echo "<br>"; echo "$scripture"; echo "<hr>"; } if(!$query){ echo "<b>You did NOT enter any keywords.</b><br>"; } if(!$scripture){ echo "<b>No results found.</b>"; } } } Is there a function to find first integer in the string and insert a : before it? Is there an easy way to find a numeric value in a string if I don't know what the string will contain? For example I want '52' out of: mystring52 Hopefully there is already a simple function to do this? I'm thinking there may not be as the string having more than one group of numbers may confuse matters. I'm just dealing with abcdef123 or similar in this case though. I have another question related to string searches. What I have is a string of couple thousand characters of all types but the date format is allways the same: dd-mth-year (two digits for day-three letters for month-four digits for year). Can I use the format alone to determine where the date is located which in turn would make it very easy to store that date into variables for inserting into database, etc. Is there anyway to tell php the format to look for or do I have to have actual numbers/letters to perform the search? Hi all, 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. can i do this? i don't want to use the this code Code: [Select] <? $coconut = $str[3]; echo "$coconut"; ?> can someone help? Thank you, Best Regards if i want find included a word in the a range how can i do it? example : Quote array("problem is an obstacle, impediment, difficulty or challenge, or any situation that invites resolution; the resolution of which is recognized as a solutionquestion raised for inquiry, consideration, or solution proposition in mathematics or physics stating something to be done"); how can i find only start 20 charecter and my found word after 20 character by end example :if my word be inquiry i want find :...soluti Quote onquestion raised for inquiryconsideration, or solution proposition... [/size] Hello, I have a few strings that contain dates along with some other text. The string looks like this: Code: [Select] Hi, could you please add these dates to the database?<br /> <br /> <br /> 2-September-2011<br /> 6-September-2011<br /> 7-September-2011<br /> 8-September-2011<br /> 9-September-2011<br /> <br /> Thank you. Dates are always the same format. Sometimes there's a single date, most times there are multiple. Does anyone know how can I get the dates from this string to add them to my sql database? Thank you! Hello everyone, I am trying to select and return any rows that have a specific string in it. Let's say I have a column name "item_id" and in every row of that column I have values like so: row A: (11,22,44,34) row B: (12,56,78,98) If the user picks the number '22', I use the following SQL line to get the row in which the number '22' is contained. SELECT * FROM Persons WHERE City LIKE '%22%' and row A gets returned, just like it is suppose to. The problem is, if the user selects a single digit number like '2', both row A and row B gets returned because they both have values that contain the number '2' in it. Instance, row A has the number '22' and row B has the number '12' so both rows get returned when the number '2' is requested. I don't want that, I only want the row that has the exact number '2' or '34' or whatever number I request, to be returned. So to get around this problem, I am wrapping my numbers in letters like so: row A: (a11a,a22a,a44a,a34a) row B: (a12a,a56a,a78a,a98a,a2a) and requesting it like so: SELECT * FROM Persons WHERE City LIKE '%a22a%' My question is: Is there a better way to work out this logic? Hi
I have a MySql database and wondered if there is a code to search a table field with a given string and display the number of unique occurrences.
The table is asterisk_cdr and would like to know how many calls received daily on a perticular channel.
Thanks
shmideo
Is it pasible to find all occurrences of strings "North" and "North-East" in some txt file and save number of occurrences in some variables?? Hi, I have a php code that is used to find all the images in a website using simple_html_dom. When I tried to run it, this error occured:
Fatal error: Call to a member function find() on a non-object in C:\xampp\htdocs\myPHP\index.php on line 20
This is my code:
<!DOCTYPE html> <html> <body> <?php include_once("simple_html_dom.php"); //use curl to get html content function getHTML($url,$timeout) { $ch = curl_init($url); // initialize curl with given url curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); // set useragent curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // write the response to a variable curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // follow redirects if any curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); // max. seconds to execute curl_setopt($ch, CURLOPT_FAILONERROR, 1); // stop when it encounters an error return @curl_exec($ch); } $html=getHTML("http://www.website.com",10); // Find all images on webpage foreach($html->find("img") as $element) echo $element->src . '<br>'; ?> </body> </html>I have the simple_html_dom.php file in my directory. How can I correct this? thanks Edited by Raex, 20 August 2014 - 09:05 PM. I wanted to replace a strings in a large text file .. what would be the fastest way ?! e.g the text file contains .. INSERT INTO `subjects` VALUES (1, 'some text here', 'some text here', 'some text here'); INSERT INTO `subjects` VALUES (2, 'some text here', 'some text here', 'some text here'); INSERT INTO `subjects` VALUES (3, 'some text here', 'some text here', 'some text here'); INSERT INTO `subjects` VALUES (4, 'some text here', 'some text here', 'some text here'); INSERT INTO `subjects` VALUES (5, 'some text here', 'some text here', 'some text here'); I wanted to replace the string " VALUES (1, " with "VALUES (" in each line .. I'm new in PHP so any response would be much appreciated .. thanks
Hi all dear
<!DOCTYPE html> <html> <body> <?php function generatePermutation($string,$start,$end){ if($start == $end-1){ echo "$string - "; } else{ for($i = $start; $i < $end; $i++){ $temp = $string[$start]; $string[$start] = $string[$i]; $string[$i] = $temp; generatePermutation($string,$start+1,$end); $temp = $string[$start]; $string[$start] = $string[$i]; $string[$i] = $temp; } } } $str = "ABC"; $n = strlen($str); echo "All the permutations of the string a "; generatePermutation($str,0,$n); ?> </body> </html>
Part of my page is taken from external webpages by preg_match. Since It is a partial section, it contains incomplete tags such as <div>, <span>, etc. Thus, they mix up with my entire page and my </div>, </span> are used for the incomplete tags in the borrowed section. How I can end such tags? or separate this section from the main codes (I mean having an isolated section)? try { echo "<br>"; foreach($dbh->query("SELECT * FROM test_shot WHERE sold=1 ORDER BY year ASC") as $row) { if($row['picture'] != "" && $row['picture'] != null) { echo "<div class='image-holder'><img src ='".$row['picture']."' width=300px /><br>"; } if($row['year'] != "" && $row['year'] != null) { echo $row['year']; } if($row['description'] != "" && $row['description'] != null) { echo $row['description']; } if($row['sold'] == 1) { echo "<img src='images/sold1.png'><br>";//Add your image code here } elseif ($row['sold'] == 0) { echo "</div><br>"; } } } catch (PDOException $e) { print $e->getMessage(); } ?>
|