PHP - How To Find Date Within A String?
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? 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 Hi, I am trying to convert a String date into numeric date using PHP function's, but haven't found such function. Had a look at date(), strtotime(), getdate(); e.g. Apr 1 2011 -> 04-01-2011 Could someone please shed some light on this? Regards, Abhishek 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 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? 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'; 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. 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! 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 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?? 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? Start with: Saturday August 13 1978. What is the next year that August 13th falls on a Saturday? Couldn't find an answer to that anywhere! 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 What is the easiest way of finding out in php what date a certain day falls on? ie: I want to know what date is the 3rd Thursday of every month. for example, this month would be " The third Thursday of this month falls on : 18th November " Whats the best way of doing that in php? 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>
PLEASEEE no matter what i do... datepicker always post the dates as string i do whatever ways know convert string to date but no way!! how convert string to date so i can sarch in a mysql table... tnx in advanced <!--HTML-->
<div class="control-group"> <!--PHP-->
$yfromx=$_POST['from'] ;
$t1=gettype ( $yfromx ) ;
Hi Guys, I have got a date string which looks like the following: Quote Thu Feb 09 2012 07:25:00 GMT 0000 (GMT Standard Time) I need to convert it to Quote d-m-Y H:i format. Any ideas on how to do this? Thanks! |