PHP - Regex In Php Array [numbers]
Hi
I would like to use regex in php for this array :
$strings = array("words", "test" ,"1=1"); words and test is ok , but I want set 1=1 like $i=$i for any value (just numbers) 2=2 or 10=10 and .... Similar TutorialsNOTE - Please read the information first as it contains important information to understand the problem. Rules → • There are 9 Columns(C1,C2,C3,C4,C5,C6,C7,C8,C9) [ Max columns will be 9] • The number of Rows can vary from 3,6,9,12,15,18 (Max). In this case Number of Rows shall be 12 Number of Rows = No of Tickets (Max Allowed 6) x Rows Per Ticket (Max Allowed 3). Thus, Max Rows can be 18 • Each Row is required to have 4 Blank Spaces and 5 Filled with Numbers • All numbers available in the Column Array have to be utilized • This configuration of an shall create a matrix of 9 Columns & 12 Rows (3 x 4 Tickets), which is 108 MATRIX BLOCKS where only a maximum of 60 numbers can be filled out of 108 available blocksrandomly with the above conditions being met 100%. • The numbers in column must be arranged / sorted in ASCENDING ORDER (For coding logic purpose, as soon as the number is assigned to the new MATRIX MAP use array_shift() or unset() the number so as to avoid repetition Example - Row 1 and Column 1 shall generate a MATRIX BLOCK - R1C1 Row 3 and Column 7 shall generate a MATRIX BLOCK - R3C7 Matrix Block can also be termed as Matrix Cell for your ease (if needed) MASTER SET OF ARRAY WITH NUMBERS array( "C1"=> array( 1, 2, 3, 5, 6, 7, 9 ), //7 Numbers "C2"=> array( 13, 14, 15, 17, 18, 19 ), //6 Numbers "C3"=> array( 21, 22, 23, 24, 25, 26, 30 ), //7 Numbers "C4"=> array( 31, 33, 34, 36, 37, 38, 39 ), //7 Numbers "C5"=> array( 41, 42, 46, 47, 48, 49, 50 ), //7 Numbers "C6"=> array( 51, 52, 53, 54, 55, 57, 58 ), //7 Numbers "C7"=> array( 61, 62, 64, 65, 69, 70 ), //6 Numbers "C8"=> array( 71, 74, 75, 76, 77, 78 ), //6 Numbers "C9"=> array( 82, 83, 85, 87, 88, 89, 90 ) //7 Numbers ); The above array has 60 Numbers to be filled out of 108 MATRIX BLOCK / CELL which meets the condition that for a FULL BLOCK containing 4 MINI BLOCKS WITH 3 ROWS (max. allowed) EACH I have been able to generate this without any issue meeting all the conditions of the Columns My Allocation Matrix Array will look like array( "R1"=> array( "C1"=> true, // Means that MATRIX BLOCK R1C1 will be NOT EMPTY "C2"=> false, // Means that MATRIX BLOCK R1C2 will be EMPTY "C3"=> true, "C4"=> false, "C5"=> true, "C6"=> false, "C7"=> true, "C8"=> true, "C9"=> false ), "R2"=> array( "C1"=> false, "C2"=> true, "C3"=> false, "C4"=> true, "C5"=> false, "C6"=> true, "C7"=> true, "C8"=> true, "C9"=> false ), "R3"=> array( "C1"=> true, "C2"=> true, "C3"=> true, "C4"=> true, "C5"=> false, "C6"=> false, "C7"=> false, "C8"=> false, "C9"=> true ), "R4"=> array( "C1"=> true, "C2"=> true, "C3"=> true, "C4"=> false, "C5"=> true, "C6"=> true, "C7"=> false, "C8"=> false, "C9"=> false ), "R5"=> array( "C1"=> false, "C2"=> false, "C3"=> false, "C4"=> false, "C5"=> true, "C6"=> true, "C7"=> true, "C8"=> true, "C9"=> true ), "R6"=> array( "C1"=> true, "C2"=> true, "C3"=> false, "C4"=> true, "C5"=> false, "C6"=> true, "C7"=> false, "C8"=> false, "C9"=> true ), "R7"=> array( "C1"=> false, "C2"=> false, "C3"=> true, "C4"=> false, "C5"=> true, "C6"=> false, "C7"=> true, "C8"=> true, "C9"=> true ), "R8"=> array( "C1"=> true, "C2"=> false, "C3"=> false, "C4"=> true, "C5"=> false, "C6"=> false, "C7"=> true, "C8"=> true, "C9"=> true ), "R9"=> array( "C1"=> true, "C2"=> false, "C3"=> true, "C4"=> false, "C5"=> true, "C6"=> true, "C7"=> false, "C8"=> false, "C9"=> true ), "R10"=> array( "C1"=> false, "C2"=> true, "C3"=> true, "C4"=> true, "C5"=> true, "C6"=> false, "C7"=> true, "C8"=> false, "C9"=> false ), "R11"=> array( "C1"=> false, "C2"=> true, "C3"=> false, "C4"=> true, "C5"=> true, "C6"=> true, "C7"=> false, "C8"=> true, "C9"=> false ), "R12"=> array( "C1"=> true, "C2"=> false, "C3"=> true, "C4"=> true, "C5"=> false, "C6"=> true, "C7"=> false, "C8"=> false, "C9"=> true ) ); In the above array R stands for Row, C for Column, TRUE/FALSE (Boolean) means that if TRUE a Number can be filled in the resulting MATRIX BLOCK / CELL ( Row[Number]Column[Number] ) else if FALSE the MATRIX BLOCK / CELL shall be EMPTY The result for the above shall be
PROBLEM : I am unable to understand what should possibly be the logic & loop used here for creating a MATRIX ALLOCATION MAP as shown above I have tried while, foreach & for but unable determine the perfect combination which would meet the conditions. (Tried all of the above with Nested Loops also) Edited May 1, 2020 by AlphaMikeTags hi, also i need to make a new array which includes all regex matches or strstr matches (it doesn't need to be regex) from the old array. now i have it like this: $array=array('cathouse','doghouse','mousehouse'); preg_match_all("@\,([a-zA-Z0-9\|]+dog[a-zA-Z0-9\|]+)\,@i",',|'.implode("|,|",$array).'|,',$matches); print_r($matches[1]); but is there a faster way to do this? (i tryed with loops but it's all slower) i also have all this in another loop. because it must match more words/strings then only "dog". EDITED. Hi, all! I've got a text field in my DB, and inside it i have several date formmated like "02/02/2001". I need to find, from all the found dates, which one is the newest. I thought using regex 'd be nice, am i right? Googlin, i've found http://www.roscripts.com/PHP_regular_expressions_examples-136.html, which lead me using something like: Code: [Select] function do_reg($text, $regex) { preg_match_all($regex, $text, $result, PREG_PATTERN_ORDER); for ($i = 0; $i < count($result[0]); $i++) { $result[0][$i]; } } But the given expressions are for cheking if there is any invalid date: Code: [Select] //Date yyyy-mm-dd //1900-01-01 through 2099-12-31 //Matches invalid dates such as February 31st '(19|20)[0-9]{2}[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])' So, anyone? P.s.: this is because i'm importing a full-messed 'DB'. Thanks! $bl = array(); $link1 = array_rand($cds); $link2 = array_rand($cds); $link3 = array_rand($cds); $link4 = array_rand($cds); $A = 0; while (!in_array($link1, $bl)){ $link1 = array_rand($cds); $bl[$A] = $link1; $A++; } while (!in_array($link2, $bl)){ $link2 = array_rand($cds); $bl[$A] = $link2; $A++; } while (!in_array($link3, $bl)){ $link3 = array_rand($cds); $bl[$A] = $link3; $A++; } while (!in_array($link4, $cds)){ $link4 = array_rand($cds); $bl[$A] = $link4; $A++; } echo $link1; echo $link2; echo $link3; echo $link4; Pretty much I'm trying to generate 4 number's between the min and max of an array but I don't want any duplicates. So it checks if the number exists in a bl array if it does it generates another number, well thats the theory. Doesn't work like that though. I have a cards array, and I have this function which will shuffle the cards for me. How can I edit this to 'deal' 12cards (6 & 6) until all the cards are a specific 6 & 6 I pick out? Code: [Select] function ShuffleCards(&$cardsArray, $times) { // Randomizes where to split within center (-3 to +3 from dead center) (MINIMUM 10 CARDS IN DECK) // Splits into two array. Randomizes how many cards from left and how many cards from right (between 1 and 3) // Alternates sides. Continues until both arrays are empty. $arraySize = count($cardsArray); if($arraySize<10) return; $deadCenter = $arraySize/2; for($i=0;$i<$times;$i++) { reset($cardsArray); $cutVariant = rand(-3, 3); $cutLocation = $deadCenter+$cutVariant; $firstArray = array(); $secondArray = array(); for($z=0;$z<$arraySize;$z++) { if($z<$cutLocation) array_push($firstArray, $cardsArray[$z]); else array_push($secondArray, $cardsArray[$z]); } $bottomFirst = rand(0, 1); $cardsArray = array(); while(count($firstArray) && count($secondArray)) { $leftNewCards = array(); $rightNewCards = array(); $leftVariant = rand(1, 3); if($leftVariant>count($firstArray)) $leftVariant = count($firstArray); $rightVariant = rand(1, 3); if($rightVariant>count($secondArray)) $rightVariant = count($secondArray); for($x=0;$x<$leftVariant;$x++) { array_push($leftNewCards, array_shift($firstArray)); } for($y=0;$y<$rightVariant;$y++) { array_push($rightNewCards, array_shift($secondArray)); } if($bottomFirst==0) { $newCardsArray = array_merge($leftNewCards, $rightNewCards); $bottomFirst = 1; } else { $newCardsArray = array_merge($rightNewCards, $leftNewCards); $bottomFirst = 0; } reset($newCardsArray); while(count($newCardsArray)) { array_push($cardsArray, array_shift($newCardsArray)); } } if(count($firstArray)) { while(count($firstArray)) array_push($cardsArray, array_shift($firstArray)); } if(count($secondArray)) { while(count($secondArray)) array_push($cardsArray, array_shift($secondArray)); } } } Hello all, I am newbie to php programming, any suggestions or advance greatly appreciated. I can't figure out how to output two array random numbers in ascending order. <?php $l_numbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47); $mega = range(1, 27); for($i = 0; $i <= 4; $i++) { $random1 = array_rand($l_numbers); echo "$random1 \n" ; } for($e = 1; $e <= 1; $e++) { $random2 = array_rand($mega); echo "<p> Mega number is $random2 </p>"; } echo "Winning numbers are $random1 and mega $random2"; ?> example: Winning numbers are 3,5,10,17,39 and mega 5. So I already have this below...
$state = array ( Can those numbers be a range -- 1-16, 17-32, 33-48 and 49-64 -- without just listing them all?
The Script:
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"> <input type="text" name="hashtags" /> <input type="submit" name="submit" /> </form> <?php include("connect.php"); ?> <?php if(isset($_POST['submit'])){ $hashtags = explode(", ", $_POST['hashtags']); for($i= 0; $i < count($hashtags); $i++){ $tqs = "SELECT `id` FROM `hashtags_two` WHERE `hashtags` = '" . $hashtags[$i] . "'"; $tqr = mysqli_query($dbc, $tqs) or die(mysqli_error($dbc)); } $fetch_array = array(); while($row = mysqli_fetch_array($tqr)){ $fetch_array[] = $row['id']; } }Hey, sorry for these fundamental array questions lately, I am not going to ask much more when it comes to this. The hashtags come from the submit form (separated by commas) and get stored inside an array with the "explode()" function. The script should select the ID numbers of the hashtags from the table. With the script above only the last row gets inserted into $fetch_array inside the while loop. When the $fetch_array variable is printed on screen then only one ID number can be seen inside the array: Array ( [0] => 24 )How can I have the other ID numbers too? Hello, I am fairly new to PHP and I found some php code to print an array of numbers that create a combination - however, its slams all the numbers together without a space or a comma separator. How can I separate the numbers in this array with the given code? Ive attached a photo of the code.
Hi, I need to sort variables in groups of up to 15 and put it in an array. For example: $exstract['center_tabOpBody_0'] =5 $exstract['center_tabOpBody_1'] =6 $exstract['center_tabOpBody_2'] =8 $exstract['center_tabOpBody_3'] =1 Should yield: ARRAY( = center_tabOpBody_1,center_tabOpBody_2,center_tabOpBody_3 // <-----15 [1] = center_tabOpBody_0 //<----5 ) Is there some simple function do do the "efficiency" sort? Thanks, Vadim Ok, my first post here (earlier today) was a huge help, so here's a second... I have the following PHP code: $name = $row['NAME']; $nameTrimmed = $name; if ((strlen($nameTrimmed) > 20) && (strlen($nameTrimmed) > 1)) { $whitespaceposition2 = strrpos($nameTrimmed," ",5); $nameTrimmed = substr($nameTrimmed, 0, $whitespaceposition2); echo $nameTrimmed . "..."; } if ((strlen($name) <= 20) && (strlen($name) > 0)) { echo $name; } This is working as expected. However, many of the "name" fields in the DB contain &trade; and &reg; strings, which inflate the count of each product title. Since I'm using the strrpos to limit the length of the longer product names (due to limited space in the layout), I would like to show as many full titles as possible. Many are being cut prematurely short due to the extra characters from the symbols. Do I need to run all this through a regex filter before I count it? If so, can anyone share an example of code I could try? Regex has never been my weak point, let alone my strong point. Or is there something else I haven't thought of? Any help is greatly appreciated! Hey Guys,
I'm receiving an api request back that looks like:
[{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174222182518,"lsrc":80972326202,"ltgt":31581262572,"luuu":"groups.google.com/group/comp.infosystems.www.users/msg/9a210e5f72278328","pda":100,"ueid":355370,"uid":358079,"ulc":1394603890,"umrp":7.348021108330069,"umrr":4.2306065019844527e-07,"upa":95.04277845195264,"us":200,"ut":"HTTP cookie - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/HTTP_cookie"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174457993090,"lsrc":80972326202,"ltgt":31622557610,"luuu":"support.google.com/chrome/answer/95582?hl=en","pda":100,"ueid":355370,"uid":358079,"ulc":1394603890,"umrp":7.348021108330069,"umrr":4.2306065019844527e-07,"upa":95.04277845195264,"us":200,"ut":"HTTP cookie - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/HTTP_cookie"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174457997214,"lsrc":80972326202,"ltgt":31622557668,"luuu":"support.google.com/chrome/answer/95626?hl=en","pda":100,"ueid":355370,"uid":358079,"ulc":1394603890,"umrp":7.348021108330069,"umrr":4.2306065019844527e-07,"upa":95.04277845195264,"us":200,"ut":"HTTP cookie - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/HTTP_cookie"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174704422109,"lsrc":80972326202,"ltgt":31675615115,"luuu":"www.google.com/support/chrome/bin/answer.py?hl=en&answer=95582","pda":100,"ueid":355370,"uid":358079,"ulc":1394603890,"umrp":7.348021108330069,"umrr":4.2306065019844527e-07,"upa":95.04277845195264,"us":200,"ut":"HTTP cookie - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/HTTP_cookie"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174704422260,"lsrc":80972326202,"ltgt":31675615123,"luuu":"www.google.com/support/chrome/bin/answer.py?hl=en&answer=95626","pda":100,"ueid":355370,"uid":358079,"ulc":1394603890,"umrp":7.348021108330069,"umrr":4.2306065019844527e-07,"upa":95.04277845195264,"us":200,"ut":"HTTP cookie - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/HTTP_cookie"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051896270,"lsrc":80975346908,"ltgt":31567049373,"luuu":"books.google.com/?id=0IZboamhb5EC&lpg=PA731","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051900386,"lsrc":80975346908,"ltgt":31567051168,"luuu":"books.google.com/?id=58KxPNa0hF4C&lpg=PA463","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051902110,"lsrc":80975346908,"ltgt":31567051879,"luuu":"books.google.com/?id=6xiYiybkE8kC&vq=core","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051902955,"lsrc":80975346908,"ltgt":31567052243,"luuu":"books.google.com/?id=7veohk0fkLYC&lpg=PA88","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051904343,"lsrc":80975346908,"ltgt":31567052883,"luuu":"books.google.com/?id=9iQYSQ9y60MC&lpg=PA49","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051905960,"lsrc":80975346908,"ltgt":31567053635,"luuu":"books.google.com/?id=BgZyXNIrvB4C&pg=PT12","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051911261,"lsrc":80975346908,"ltgt":31567055934,"luuu":"books.google.com/?id=Ho_RmgOnwgwC&lpg=PA8","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051913146,"lsrc":80975346908,"ltgt":31567056717,"luuu":"books.google.com/?id=JttyjBoyb3AC&lpg=PA12","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051920509,"lsrc":80975346908,"ltgt":31567059840,"luuu":"books.google.com/?id=SF7U27JsLC4C&dq=iraq+invasion+removes+hussein","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051921673,"lsrc":80975346908,"ltgt":31567060362,"luuu":"books.google.com/?id=T_0TrXXiDbUC&dq=slavery+%22American+Civil+War%22","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051922547,"lsrc":80975346908,"ltgt":31567060715,"luuu":"books.google.com/?id=UYpVAAAAYAAJ","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051925466,"lsrc":80975346908,"ltgt":31567061980,"luuu":"books.google.com/?id=Y1dOLQN9hvwC&dq=SEALs+kill+Osama+bin+Laden","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051936195,"lsrc":80975346908,"ltgt":31567066473,"luuu":"books.google.com/?id=jLy-NKnQitIC&pg=PA45&dq=uk+us+special+relationship","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051937261,"lsrc":80975346908,"ltgt":31567066890,"luuu":"books.google.com/?id=ka6LxulZaEwC&vq=annexation&dq=territorial+expansion+United+States+%22manifest+destiny%22","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051943179,"lsrc":80975346908,"ltgt":31567069364,"luuu":"books.google.com/?id=r71u_AgE7iYC&lpg=PA142","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051949934,"lsrc":80975346908,"ltgt":31567072219,"luuu":"books.google.com/?id=yd4GqkP5XYgC&lpg=PA229","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174051950951,"lsrc":80975346908,"ltgt":31567072673,"luuu":"books.google.com/?id=zq4rsWNrYo4C&q=Reaganomics&dq=Reaganomics","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174052414947,"lsrc":80975346908,"ltgt":31567405066,"luuu":"books.google.com/books/about/A_History_of_the_American_People.html?id=RXSVQjz1_tMC","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174052676940,"lsrc":80975346908,"ltgt":31567608329,"luuu":"books.google.com/books/about/An_Empire_of_Wealth.html?id=rmsUs_KDgHAC","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"},{"fmrp":8.770560720053982,"fmrr":7.78614635427592e-05,"lrid":174054227159,"lsrc":80975346908,"ltgt":31568894639,"luuu":"books.google.com/books/about/History_of_the_American_Economy_With_Acc.html?id=lyhI1q_E4G0C","pda":100,"ueid":73314,"uid":156486,"ulc":1393624567,"umrp":6.978036065267593,"umrr":1.3614443568106348e-07,"upa":94.43262161988372,"us":200,"ut":"United States - Wikipedia, the free encyclopedia","uu":"en.wikipedia.org/wiki/United_States"}]I'm trying to retrieve all the backlinks located in these parts: "uu":"en.wikipedia.org/wiki/HTTP_cookie" "uu":"en.wikipedia.org/wiki/United_States" etc I tried this regex: $regex = returnSeoMozLinks("google.com"); $pattern = '""uu"":""(.*?)""'; $success = preg_match($pattern, $regex, $match); if ($success) { echo "Match: ".$match[0]."<br />"; }But it doesn't seem to work, i can do it in vb net but i am rusty with php lol any help would be appreciated guys! cheers Graham I want to make it so if($message=="" . $cmdPrefx . "deleteall: "){ echo substr(strrchr($message, ' '), 1); Doesn't use =="something" How can I make it so anything after deleteall: is a wildcard? I'm assuming using regex, but have no idea how I have a CSV file which has more than 50k records and i want to convert this using regex hello. There is a project i take and i can't handle it. the project goes like this. I get site code by file_get_contents function into variable. Than I need to find the iframe and delete it from the variable. for example the code i getting from the file_get_contents is looking like this : <html> <body> This is site ! <iframe> LINK </iframe> </body> </html> now , simply i can track the iframe and delete it just like this. $str = preg_replace('/\<{1}iframe[a-zA-Z0-9=+\/\'.]/' , '' , $str);/** this is not the right regex i use , the full one contain all chars except < .**/ So I can find the < symbol and than delete all iframe section. the problem come when I get code like this. <html> <body> This is site ! <iframe> <iframe>LINK </iframe></iframe> </body> </html> So , from here I can't handle it since I don't know where the iframe ends since there is many < symbols. Second question is maybe with regex i can handle something like this? looking for start , than get everything between and stop at the end. $reg ='/^\<{1}iframe .+\<{1}iframe\>{1}/i'; Is that possible to do something like this with regex? any suggestions how to make it done? hope i was clear. thanks , Mor. Well I'm stuck... So I'm trying to make the php print out the text between Code: [Select] title="Text here" <?php function Betweens($string) { $pattern = '/title="(.*?)"/'; //It fails here preg_match($pattern, $string, $matches); return $matches[1]; } $str = '<iu pageid="2022" ns="0" title="Test" />'; $p = Betweens($str); echo $p; ?> So yea I really suck at regex's.. Edit: God damn it, now I see I've posted in wrong sector -.- I have been playing with reg ex patterns for the last couple of hours. I realized I have been coding in security a hole. But for the life of me I don't know the answer. In preg match it will return a 1 true. So the code below is saying if you find anything that is not one of these values the condition is true. Meaning anything but a-zA-Z true is this correct? How do I make it so if you find anything but a-zA-Z return false? Code: [Select] if ( preg_match('/[a-zA-Z]/', $_GET['contact'] )== 1) hey guys im after the pattern to replace , and & symbols please?...any help would be great
thank you
|