For some reason that last array is returning NULL. It's supposed to be returning "H11": <?php $all_description_blb = array(); $all_etymologyStrongs = array(); $string1 = ""; $string2 = ""; $string3 = ""; $string4 = ""; $blbdescription = "<span style=\"color: red; font-weight: bold;\"> The same as <a class=\"nowrap\" href=\"lexicon.cfm?strongs=H9&t=KJV\" title=\"English: lost thing, that which was lost\"><span class=\"Hb\">אֲבֵדָה</span> (H9)</a>, incorrectly written for <a class=\"nowrap\" href=\"lexicon.cfm?strongs=H11&t=KJV\" title=\"English: destruction\"><span class=\"Hb\">אֲבַדּוֹן</span> (H11)</a> </span>"; preg_match_all("#<\b(a)\b[^>]*>(.*?)</\b(a)\b>#si", $blbdescription, $stripatag, PREG_SET_ORDER); array_push($all_description_blb, $blbdescription); $string1 .= "-----<br /><br />\n"; $string1 .= "stripatag <pre style=\"color: red; font-weight: bold;\">"; //var_dump($stripatag); $string2 .= "</pre> "; $string2 .= "<br /><br />\n"; $string3 .= "-----<br /><br />\n"; $string3 .= "stripbracketsforetymstrongsarray <pre style=\"color: red; font-weight: bold;\">"; $string4 .= "-----<br /><br />\n"; $string4 .= "stripatag [0][2] <span style=\"color: green; font-weight: bold;\">".$stripatag[0][2]."</span><br /><br />\n"; $string4 .= "stripatag [1][2] <span style=\"color: green; font-weight: bold;\">".$stripatag[1][2]."</span><br /><br />\n";//Notice: Undefined offset: 1 in C:\xampp\htdocs\biblewheel\update_outline\index.php on line 228 $string2 .= "---------------------------------------------------------------<br /><br />\n"; for($a=0;$a<count($stripatag);$a++){ preg_match_all("/.*\(([^)]*)\)/", $stripatag[$a][2], $stripbracketsforetymstrongsarray, PREG_SET_ORDER); $etymologyStrongs = $stripbracketsforetymstrongsarray[$a][1];//$href[$a][2] or $href3array[$a][2]? array_push($all_etymologyStrongs, $etymologyStrongs); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php echo $string1; var_dump($stripatag); echo $string2; echo $string3; var_dump($all_etymologyStrongs); echo $string2; echo $string4; ?> </body> </html> PHP:
It seems like there should be $etymologyStrongs = $stripbracketsforetymstrongsarray[0][1];//$href[$a][2] or $href3array[$a][2]? PHP: instead of $etymologyStrongs = $stripbracketsforetymstrongsarray[$a][1];//$href[$a][2] or $href3array[$a][2]? PHP:
This comes close to what I'm looking for but there are still notices: <?php $all_description_blb = array(); $all_etymologyStrongs = array(); $string1 = ""; $string2 = ""; $string3 = ""; $string4 = ""; $blbdescription = "<span style=\"color: red; font-weight: bold;\"> The same as <a class=\"nowrap\" href=\"lexicon.cfm?strongs=H9&t=KJV\" title=\"English: lost thing, that which was lost\"><span class=\"Hb\">אֲבֵדָה</span> (H9)</a>, incorrectly written for <a class=\"nowrap\" href=\"lexicon.cfm?strongs=H11&t=KJV\" title=\"English: destruction\"><span class=\"Hb\">אֲבַדּוֹן</span> (H11)</a> </span>"; preg_match_all("#<\b(a)\b[^>]*>(.*?)</\b(a)\b>#si", $blbdescription, $stripatag, PREG_SET_ORDER); array_push($all_description_blb, $blbdescription); $string1 .= "-----<br /><br />\n"; $string1 .= "stripatag <pre style=\"color: red; font-weight: bold;\">"; //var_dump($stripatag); $string2 .= "</pre> "; $string2 .= "<br /><br />\n"; $string3 .= "-----<br /><br />\n"; $string3 .= "stripbracketsforetymstrongsarray <pre style=\"color: red; font-weight: bold;\">"; $string4 .= "-----<br /><br />\n"; $string4 .= "stripatag [0][2] <span style=\"color: green; font-weight: bold;\">".$stripatag[0][2]."</span><br /><br />\n"; $string4 .= "stripatag [1][2] <span style=\"color: green; font-weight: bold;\">".$stripatag[1][2]."</span><br /><br />\n";//Notice: Undefined offset: 1 in ...\index.php on line 228 $string2 .= "---------------------------------------------------------------<br /><br />\n"; for($a=0;$a<count($stripatag);$a++){ preg_match_all("/.*\(([^)]*)\)/", $stripatag[$a][2], $stripbracketsforetymstrongsarray, PREG_SET_ORDER); for($b=0;$b<count($stripatag[$a]);$b++){ $etymologyStrongs = $stripbracketsforetymstrongsarray[$b][1];//Line 34 is this $href[$a][2] or $href3array[$a][2]? array_push($all_etymologyStrongs, $etymologyStrongs); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php echo $string1; var_dump($stripatag); echo $string2; echo $string3; var_dump($all_etymologyStrongs); echo $string2; echo $string4; ?> </body> </html> PHP: But is it possible of doing in one for loop instead of 2: $a and $b? It shows the following:
This works: http://sandbox.onlinephpfunctions.com/code/0ce2fc04eca2d03f6b684a2dd84a1d8918c97e5b <?php $blbdescription = "<span style=\"color: red; font-weight: bold;\"> (G4) The same as <a class=\"nowrap\" href=\"lexicon.cfm?strongs=H9&t=KJV\" title=\"English: lost thing, that which was lost\"><span class=\"Hb\">אֲבֵדָה</span> (H9)</a>, incorrectly written for <a class=\"nowrap\" href=\"lexicon.cfm?strongs=H11&t=KJV\" title=\"English: destruction\"><span class=\"Hb\">אֲבַדּוֹן</span> (H11)</a> </span>"; preg_match_all('/\([H|G]{1}([0-9]+)\)/', $blbdescription, $res); print_r($res); PHP: Also avoid variable names that are soooooooo long.
Yes this does open perhaps an easier way for the php coding. I might need to make big changes in my coding. I know what you mean about the long variable names however months down the road when I look back at the codes I want to be able to recognize them. Is it a good thing to add a tag attributes in a db table? or is there a better way to break them down and most importantly add the titles in the a tags in a separate column? Also is there a way to strip the brackets but leave the letters with the numbers: Instead of:
Update the regular expression to include the letter part of the match: <?php preg_match_all('/\(([H|G]{1}[0-9]+)\)/', $blbdescription, $res); Code (markup): Also take a min to check this out: https://regex101.com/r/xmrbJN/1 will explain to you exactly what is going on with the regular expression.