How to search by skipping equidistant letters

Ok I put together in one page the string and keyword to search for with a skip of equidistant letter sequences:

<!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>Bible Code Example</title>
</head>

<body>
<input id="skiprow" type="text" value="50" />
<input id="word" type="text" value="&#1514;&#1493;&#1512;&#1492;" />
<a href="JavaScript: ext='?skiprow='+document.getElementById('skiprow').value+'&word='+document.getElementById('word').value; window.location=ext;">search this</a><br /><br />
<?php
$skiprow=isset($_GET['skiprow']) ? $_GET['skiprow'] : '';
$word=isset($_GET['word']) ? $_GET['word'] : '';

$text_of_this_chapter="&#1489;&#1512;&#1488;&#1513;&#1497;&#1514;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1488;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1492;&#1488;&#1512;&#1510;&#1492;&#1497;&#1514;&#1492;&#1514;&#1492;&#1493;&#1493;&#1489;&#1492;&#1493;&#1493;&#1495;&#1513;&#1499;&#1506;&#1500;&#1508;&#1504;&#1497;&#1514;&#1492;&#1493;&#1502;&#1493;&#1512;&#1493;&#1495;&#1488;&#1500;&#1492;&#1497;&#1502;&#1502;&#1512;&#1495;&#1508;&#1514;&#1506;&#1500;&#1508;&#1504;&#1497;&#1492;&#1502;&#1497;&#1502;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1488;&#1493;&#1512;&#1493;&#1497;&#1492;&#1497;&#1488;&#1493;&#1512;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1488;&#1493;&#1512;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1489;&#1491;&#1500;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1497;&#1504;&#1492;&#1488;&#1493;&#1512;&#1493;&#1489;&#1497;&#1504;&#1492;&#1495;&#1513;&#1499;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1488;&#1493;&#1512;&#1497;&#1493;&#1502;&#1493;&#1500;&#1495;&#1513;&#1499;&#1511;&#1512;&#1488;&#1500;&#1497;&#1500;&#1492;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1488;&#1495;&#1491;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1512;&#1511;&#1497;&#1506;&#1489;&#1514;&#1493;&#1499;&#1492;&#1502;&#1497;&#1502;&#1493;&#1497;&#1492;&#1497;&#1502;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1502;&#1497;&#1502;&#1500;&#1502;&#1497;&#1502;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1512;&#1511;&#1497;&#1506;&#1493;&#1497;&#1489;&#1491;&#1500;&#1489;&#1497;&#1504;&#1492;&#1502;&#1497;&#1502;&#1488;&#1513;&#1512;&#1502;&#1514;&#1495;&#1514;&#1500;&#1512;&#1511;&#1497;&#1506;&#1493;&#1489;&#1497;&#1504;&#1492;&#1502;&#1497;&#1502;&#1488;&#1513;&#1512;&#1502;&#1506;&#1500;&#1500;&#1512;&#1511;&#1497;&#1506;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1512;&#1511;&#1497;&#1506;&#1513;&#1502;&#1497;&#1502;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1513;&#1504;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1511;&#1493;&#1493;&#1492;&#1502;&#1497;&#1502;&#1502;&#1514;&#1495;&#1514;&#1492;&#1513;&#1502;&#1497;&#1502;&#1488;&#1500;&#1502;&#1511;&#1493;&#1502;&#1488;&#1495;&#1491;&#1493;&#1514;&#1512;&#1488;&#1492;&#1492;&#1497;&#1489;&#1513;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1497;&#1489;&#1513;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1502;&#1511;&#1493;&#1492;&#1492;&#1502;&#1497;&#1502;&#1511;&#1512;&#1488;&#1497;&#1502;&#1497;&#1502;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1514;&#1491;&#1513;&#1488;&#1492;&#1488;&#1512;&#1510;&#1491;&#1513;&#1488;&#1506;&#1513;&#1489;&#1502;&#1494;&#1512;&#1497;&#1506;&#1494;&#1512;&#1506;&#1506;&#1510;&#1508;&#1512;&#1497;&#1506;&#1513;&#1492;&#1508;&#1512;&#1497;&#1500;&#1502;&#1497;&#1504;&#1493;&#1488;&#1513;&#1512;&#1494;&#1512;&#1506;&#1493;&#1489;&#1493;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1514;&#1493;&#1510;&#1488;&#1492;&#1488;&#1512;&#1510;&#1491;&#1513;&#1488;&#1506;&#1513;&#1489;&#1502;&#1494;&#1512;&#1497;&#1506;&#1494;&#1512;&#1506;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1506;&#1510;&#1506;&#1513;&#1492;&#1508;&#1512;&#1497;&#1488;&#1513;&#1512;&#1494;&#1512;&#1506;&#1493;&#1489;&#1493;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1513;&#1500;&#1497;&#1513;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1502;&#1488;&#1512;&#1514;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1492;&#1497;&#1493;&#1502;&#1493;&#1489;&#1497;&#1504;&#1492;&#1500;&#1497;&#1500;&#1492;&#1493;&#1492;&#1497;&#1493;&#1500;&#1488;&#1514;&#1514;&#1493;&#1500;&#1502;&#1493;&#1506;&#1491;&#1497;&#1502;&#1493;&#1500;&#1497;&#1502;&#1497;&#1502;&#1493;&#1513;&#1504;&#1497;&#1502;&#1493;&#1492;&#1497;&#1493;&#1500;&#1502;&#1488;&#1493;&#1512;&#1514;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1488;&#1497;&#1512;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1513;&#1504;&#1497;&#1492;&#1502;&#1488;&#1512;&#1514;&#1492;&#1490;&#1491;&#1500;&#1497;&#1502;&#1488;&#1514;&#1492;&#1502;&#1488;&#1493;&#1512;&#1492;&#1490;&#1491;&#1500;&#1500;&#1502;&#1502;&#1513;&#1500;&#1514;&#1492;&#1497;&#1493;&#1502;&#1493;&#1488;&#1514;&#1492;&#1502;&#1488;&#1493;&#1512;&#1492;&#1511;&#1496;&#1504;&#1500;&#1502;&#1502;&#1513;&#1500;&#1514;&#1492;&#1500;&#1497;&#1500;&#1492;&#1493;&#1488;&#1514;&#1492;&#1499;&#1493;&#1499;&#1489;&#1497;&#1502;&#1493;&#1497;&#1514;&#1504;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1488;&#1497;&#1512;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1502;&#1513;&#1500;&#1489;&#1497;&#1493;&#1502;&#1493;&#1489;&#1500;&#1497;&#1500;&#1492;&#1493;&#1500;&#1492;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1492;&#1488;&#1493;&#1512;&#1493;&#1489;&#1497;&#1504;&#1492;&#1495;&#1513;&#1499;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1512;&#1489;&#1497;&#1506;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1513;&#1512;&#1510;&#1493;&#1492;&#1502;&#1497;&#1502;&#1513;&#1512;&#1510;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1493;&#1506;&#1493;&#1508;&#1497;&#1506;&#1493;&#1508;&#1508;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1506;&#1500;&#1508;&#1504;&#1497;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1497;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1514;&#1504;&#1497;&#1504;&#1502;&#1492;&#1490;&#1491;&#1500;&#1497;&#1502;&#1493;&#1488;&#1514;&#1499;&#1500;&#1504;&#1508;&#1513;&#1492;&#1495;&#1497;&#1492;&#1492;&#1512;&#1502;&#1513;&#1514;&#1488;&#1513;&#1512;&#1513;&#1512;&#1510;&#1493;&#1492;&#1502;&#1497;&#1502;&#1500;&#1502;&#1497;&#1504;&#1492;&#1502;&#1493;&#1488;&#1514;&#1499;&#1500;&#1506;&#1493;&#1508;&#1499;&#1504;&#1508;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1489;&#1512;&#1499;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1488;&#1502;&#1512;&#1508;&#1512;&#1493;&#1493;&#1512;&#1489;&#1493;&#1493;&#1502;&#1500;&#1488;&#1493;&#1488;&#1514;&#1492;&#1502;&#1497;&#1502;&#1489;&#1497;&#1502;&#1497;&#1502;&#1493;&#1492;&#1506;&#1493;&#1508;&#1497;&#1512;&#1489;&#1489;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1495;&#1502;&#1497;&#1513;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1514;&#1493;&#1510;&#1488;&#1492;&#1488;&#1512;&#1510;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1489;&#1492;&#1502;&#1492;&#1493;&#1512;&#1502;&#1513;&#1493;&#1495;&#1497;&#1514;&#1493;&#1488;&#1512;&#1510;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1495;&#1497;&#1514;&#1492;&#1488;&#1512;&#1510;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1488;&#1514;&#1492;&#1489;&#1492;&#1502;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1488;&#1514;&#1499;&#1500;&#1512;&#1502;&#1513;&#1492;&#1488;&#1491;&#1502;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1504;&#1506;&#1513;&#1492;&#1488;&#1491;&#1502;&#1489;&#1510;&#1500;&#1502;&#1504;&#1493;&#1499;&#1491;&#1502;&#1493;&#1514;&#1504;&#1493;&#1493;&#1497;&#1512;&#1491;&#1493;&#1489;&#1491;&#1490;&#1514;&#1492;&#1497;&#1502;&#1493;&#1489;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1489;&#1489;&#1492;&#1502;&#1492;&#1493;&#1489;&#1499;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1489;&#1499;&#1500;&#1492;&#1512;&#1502;&#1513;&#1492;&#1512;&#1502;&#1513;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1488;&#1491;&#1502;&#1489;&#1510;&#1500;&#1502;&#1493;&#1489;&#1510;&#1500;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1512;&#1488;&#1488;&#1514;&#1493;&#1494;&#1499;&#1512;&#1493;&#1504;&#1511;&#1489;&#1492;&#1489;&#1512;&#1488;&#1488;&#1514;&#1502;&#1493;&#1497;&#1489;&#1512;&#1499;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1493;&#1497;&#1488;&#1502;&#1512;&#1500;&#1492;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1508;&#1512;&#1493;&#1493;&#1512;&#1489;&#1493;&#1493;&#1502;&#1500;&#1488;&#1493;&#1488;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1499;&#1489;&#1513;&#1492;&#1493;&#1512;&#1491;&#1493;&#1489;&#1491;&#1490;&#1514;&#1492;&#1497;&#1502;&#1493;&#1489;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1489;&#1499;&#1500;&#1495;&#1497;&#1492;&#1492;&#1512;&#1502;&#1513;&#1514;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1492;&#1504;&#1492;&#1504;&#1514;&#1514;&#1497;&#1500;&#1499;&#1502;&#1488;&#1514;&#1499;&#1500;&#1506;&#1513;&#1489;&#1494;&#1512;&#1506;&#1494;&#1512;&#1506;&#1488;&#1513;&#1512;&#1506;&#1500;&#1508;&#1504;&#1497;&#1499;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1488;&#1514;&#1499;&#1500;&#1492;&#1506;&#1510;&#1488;&#1513;&#1512;&#1489;&#1493;&#1508;&#1512;&#1497;&#1506;&#1510;&#1494;&#1512;&#1506;&#1494;&#1512;&#1506;&#1500;&#1499;&#1502;&#1497;&#1492;&#1497;&#1492;&#1500;&#1488;&#1499;&#1500;&#1492;&#1493;&#1500;&#1499;&#1500;&#1495;&#1497;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1499;&#1500;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1500;&#1499;&#1500;&#1512;&#1493;&#1502;&#1513;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1488;&#1513;&#1512;&#1489;&#1493;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1488;&#1514;&#1499;&#1500;&#1497;&#1512;&#1511;&#1506;&#1513;&#1489;&#1500;&#1488;&#1499;&#1500;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1499;&#1500;&#1488;&#1513;&#1512;&#1506;&#1513;&#1492;&#1493;&#1492;&#1504;&#1492;&#1496;&#1493;&#1489;&#1502;&#1488;&#1491;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1492;&#1513;&#1513;&#1497;";
$alephbet= Array("&#1488;", "&#1489;", "&#1490;", "&#1491;", "&#1492;", "&#1493;", "&#1494;", "&#1495;", "&#1496;", "&#1497;", "&#1499;", "&#1500;", "&#1502;", "&#1504;", "&#1505;", "&#1506;", "&#1508;", "&#1510;", "&#1511;", "&#1512;", "&#1513;", "&#1514;", "&#1498;", "&#1501;", "&#1503;", "&#1507;", "&#1509;");
$alphabet= Array("a", "b", "g", "d", "h", "u", "z", "x", "w", "i", "k", "l", "m", "n", "c", "o", "p", "e", "q", "r", "f", "t", "k", "m", "n", "p", "e");
$into_alephbet= Array("&#1488;", "&#1489;", "&#1490;", "&#1491;", "&#1492;", "&#1493;", "&#1494;", "&#1495;", "&#1496;", "&#1497;", "&#1499;", "&#1500;", "&#1502;", "&#1504;", "&#1505;", "&#1506;", "&#1508;", "&#1510;", "&#1511;", "&#1512;", "&#1513;", "&#1514;");
$vm=array("&#1456;", "&#1468;", "&#1461;", "&#1460;", "&#1473;", "&#1430;", "&#1464;", "&#1457;", "&#1465;", "&#1461;", "&#1463;", "&#1473;", "&#1469;", "&#1462;", "&#1443;", "&#1425;", "&#1445;", "&#1445;", "&#1470;", "&#1431;", "&#1433;", "&#1433;", "&#1428;", "&#1428;", "&#1475;", "&#1470;", "&#1431;", "&#1433;", "&#1433;", "&#1428;", "&#1428;", "&#1447;", "&#1435;", "&#1448;", "&#1444;", " &#1472; ", "&#1474;", "&#1454;", "&#1426;", "&#1458;", "&#1458;", "&#1434;", "&#1434;", " &#1436;", "&#1440;", "&#1449;", "&#1436;", "&#1438;", "&#1429;", "&#1441;", "&#1467;", "&#1467;", "&#1459;", "&#1508;  &#1475;");
$chars=Array();
$keyword_letters=Array();
$chars=Array();
$strKeyword=$word;
for($i=0; $i<count($alephbet); $i++){
	$strKeyword=str_replace($alephbet[$i], $alphabet[$i], $strKeyword);
}
$strKeyword=str_replace(" ", "", $strKeyword);
$kw_into_letters=str_split($strKeyword);
for($eng=0; $eng<count($kw_into_letters); $eng++){
	for($heb=0; $heb<count($into_alephbet); $heb++){
		if($alphabet[$heb]==$kw_into_letters[$eng]){
			$chars[]=$into_alephbet[$heb];
		}
	}
}
echo "Looking for:".implode($chars);
for($i=0; $i<count($vm); $i++){
	$text_of_this_chapter=str_replace($vm[$i], "", $text_of_this_chapter);
}
$text_of_this_chapter=str_replace(" ", "", $text_of_this_chapter);
for($i=0; $i<count($alephbet); $i++){
	$text_of_this_chapter=str_replace($alephbet[$i], $alphabet[$i], $text_of_this_chapter);
}
$str_into_heb_letters=str_split($text_of_this_chapter);
for($i=0; $i<count($alphabet); $i++){
	$str_into_heb_letters=str_replace($alphabet[$i], $alephbet[$i], $str_into_heb_letters);
}
$string=$text_of_this_chapter;
$COLORS=array('red', 'blue');
$string_split=$str_into_heb_letters;//str_split($string);
$strlen=strlen($string);
if($skiprow=="all"){
	$skiprow=$strlen;
}
$instances=array();
$continue=true;
$pos=0;
?>
<table style="float: left; direction: rtl; text-align: left; padding: 5px;">
    <tr>
<?php //<th style="border: 1px solid black;"></th>
for($i=0; $i<$skiprow; $i++){
	$num=$i+1;
	echo "<th style=\\"border: 1px solid black; font-size: 14px;\\">".$num."</th>\
";
}
?>
    </tr>
    <tr>
<?php
while($continue){
	$instance=array();
	foreach($chars as $char){
		if(($newPos=strpos($string, $char, $pos)) !== false){
			array_push($instance, $newPos);
			$string=substr_replace($string, '#', $newPos, 1);
			$pos=$newPos;
		}else{
			$continue=false;
			break;
		}
    }
	if(count($instance)==count($chars)){
		array_push($instances, $instance);
		$pos=0;
	}
}
foreach ($instances as $i=>$instance){
	//echo 'The character at position ', $i, ' is "', $instance, '"<br />';
	$color=$COLORS[$i];
	foreach($instance as $char){
		$string_split[$char]="<td style=\\"border: 1px solid black; font-weight: bold; color: ".$color.";\\">".$string_split[$char]."</td>\
";
	}
}
foreach($string_split as $i=>$part){
	//echo 'The character at position ', $i, ' is "', $part, '"<br />';
	if (strlen($part) <3){
		$string_split[$i] = "<td style=\\"border: 1px solid black;\\">".$string_split[$i]."</td>";
	}
	if ($i % $skiprow==0 && $i>0){
		$string_split[$i] = '</tr><tr>'.$string_split[$i];
	}
}

echo implode("", $string_split);
?>
</tr>
</table> 
</body>
</html>

I would absolutely love to know what the hell is going on here. :stuck_out_tongue:

If you ever expect anyone else to maintain your code in the future, I’d leave no trace of your home address or contact details. I’d hunt you down.

I’m kidding. No I’m not. :wacko:

I’m trying to write a code which figures out or finds words in a bigger text in hebrew.
Here’s an example:

where the word love is found twice in the text, one at the skip of +4 letters and the other +2 letters.

But it’s still a challenge to search in a hebrew text, that when you split into letters it can’t show you the hebrew letters. But you have to convert to english and then reconvert to hebrew.

The problem with this code is that it’s not highlighting the searched word/code like the love example.

Ok to try to understand where the problem is I decided to convert the letters into english and try to figure out from there:

<!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>Bible Code Example</title>
</head>

<body>
<input id="skiprow" type="text" value="50" />
<input id="word" type="text" value="&#1514;&#1493;&#1512;&#1492;" />
<a href="JavaScript: ext='?skiprow='+document.getElementById('skiprow').value+'&word='+document.getElementById('word').value; window.location=ext;">search this</a><br /><br />
<?php
$skiprow=isset($_GET['skiprow']) ? $_GET['skiprow'] : '';
$word=isset($_GET['word']) ? $_GET['word'] : '';

$text_of_this_chapter="&#1489;&#1512;&#1488;&#1513;&#1497;&#1514;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1488;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1492;&#1488;&#1512;&#1510;&#1492;&#1497;&#1514;&#1492;&#1514;&#1492;&#1493;&#1493;&#1489;&#1492;&#1493;&#1493;&#1495;&#1513;&#1499;&#1506;&#1500;&#1508;&#1504;&#1497;&#1514;&#1492;&#1493;&#1502;&#1493;&#1512;&#1493;&#1495;&#1488;&#1500;&#1492;&#1497;&#1502;&#1502;&#1512;&#1495;&#1508;&#1514;&#1506;&#1500;&#1508;&#1504;&#1497;&#1492;&#1502;&#1497;&#1502;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1488;&#1493;&#1512;&#1493;&#1497;&#1492;&#1497;&#1488;&#1493;&#1512;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1488;&#1493;&#1512;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1489;&#1491;&#1500;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1497;&#1504;&#1492;&#1488;&#1493;&#1512;&#1493;&#1489;&#1497;&#1504;&#1492;&#1495;&#1513;&#1499;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1488;&#1493;&#1512;&#1497;&#1493;&#1502;&#1493;&#1500;&#1495;&#1513;&#1499;&#1511;&#1512;&#1488;&#1500;&#1497;&#1500;&#1492;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1488;&#1495;&#1491;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1512;&#1511;&#1497;&#1506;&#1489;&#1514;&#1493;&#1499;&#1492;&#1502;&#1497;&#1502;&#1493;&#1497;&#1492;&#1497;&#1502;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1502;&#1497;&#1502;&#1500;&#1502;&#1497;&#1502;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1512;&#1511;&#1497;&#1506;&#1493;&#1497;&#1489;&#1491;&#1500;&#1489;&#1497;&#1504;&#1492;&#1502;&#1497;&#1502;&#1488;&#1513;&#1512;&#1502;&#1514;&#1495;&#1514;&#1500;&#1512;&#1511;&#1497;&#1506;&#1493;&#1489;&#1497;&#1504;&#1492;&#1502;&#1497;&#1502;&#1488;&#1513;&#1512;&#1502;&#1506;&#1500;&#1500;&#1512;&#1511;&#1497;&#1506;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1512;&#1511;&#1497;&#1506;&#1513;&#1502;&#1497;&#1502;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1513;&#1504;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1511;&#1493;&#1493;&#1492;&#1502;&#1497;&#1502;&#1502;&#1514;&#1495;&#1514;&#1492;&#1513;&#1502;&#1497;&#1502;&#1488;&#1500;&#1502;&#1511;&#1493;&#1502;&#1488;&#1495;&#1491;&#1493;&#1514;&#1512;&#1488;&#1492;&#1492;&#1497;&#1489;&#1513;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1497;&#1489;&#1513;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1502;&#1511;&#1493;&#1492;&#1492;&#1502;&#1497;&#1502;&#1511;&#1512;&#1488;&#1497;&#1502;&#1497;&#1502;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1514;&#1491;&#1513;&#1488;&#1492;&#1488;&#1512;&#1510;&#1491;&#1513;&#1488;&#1506;&#1513;&#1489;&#1502;&#1494;&#1512;&#1497;&#1506;&#1494;&#1512;&#1506;&#1506;&#1510;&#1508;&#1512;&#1497;&#1506;&#1513;&#1492;&#1508;&#1512;&#1497;&#1500;&#1502;&#1497;&#1504;&#1493;&#1488;&#1513;&#1512;&#1494;&#1512;&#1506;&#1493;&#1489;&#1493;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1514;&#1493;&#1510;&#1488;&#1492;&#1488;&#1512;&#1510;&#1491;&#1513;&#1488;&#1506;&#1513;&#1489;&#1502;&#1494;&#1512;&#1497;&#1506;&#1494;&#1512;&#1506;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1506;&#1510;&#1506;&#1513;&#1492;&#1508;&#1512;&#1497;&#1488;&#1513;&#1512;&#1494;&#1512;&#1506;&#1493;&#1489;&#1493;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1513;&#1500;&#1497;&#1513;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1502;&#1488;&#1512;&#1514;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1492;&#1497;&#1493;&#1502;&#1493;&#1489;&#1497;&#1504;&#1492;&#1500;&#1497;&#1500;&#1492;&#1493;&#1492;&#1497;&#1493;&#1500;&#1488;&#1514;&#1514;&#1493;&#1500;&#1502;&#1493;&#1506;&#1491;&#1497;&#1502;&#1493;&#1500;&#1497;&#1502;&#1497;&#1502;&#1493;&#1513;&#1504;&#1497;&#1502;&#1493;&#1492;&#1497;&#1493;&#1500;&#1502;&#1488;&#1493;&#1512;&#1514;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1488;&#1497;&#1512;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1513;&#1504;&#1497;&#1492;&#1502;&#1488;&#1512;&#1514;&#1492;&#1490;&#1491;&#1500;&#1497;&#1502;&#1488;&#1514;&#1492;&#1502;&#1488;&#1493;&#1512;&#1492;&#1490;&#1491;&#1500;&#1500;&#1502;&#1502;&#1513;&#1500;&#1514;&#1492;&#1497;&#1493;&#1502;&#1493;&#1488;&#1514;&#1492;&#1502;&#1488;&#1493;&#1512;&#1492;&#1511;&#1496;&#1504;&#1500;&#1502;&#1502;&#1513;&#1500;&#1514;&#1492;&#1500;&#1497;&#1500;&#1492;&#1493;&#1488;&#1514;&#1492;&#1499;&#1493;&#1499;&#1489;&#1497;&#1502;&#1493;&#1497;&#1514;&#1504;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1488;&#1497;&#1512;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1502;&#1513;&#1500;&#1489;&#1497;&#1493;&#1502;&#1493;&#1489;&#1500;&#1497;&#1500;&#1492;&#1493;&#1500;&#1492;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1492;&#1488;&#1493;&#1512;&#1493;&#1489;&#1497;&#1504;&#1492;&#1495;&#1513;&#1499;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1512;&#1489;&#1497;&#1506;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1513;&#1512;&#1510;&#1493;&#1492;&#1502;&#1497;&#1502;&#1513;&#1512;&#1510;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1493;&#1506;&#1493;&#1508;&#1497;&#1506;&#1493;&#1508;&#1508;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1506;&#1500;&#1508;&#1504;&#1497;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1497;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1514;&#1504;&#1497;&#1504;&#1502;&#1492;&#1490;&#1491;&#1500;&#1497;&#1502;&#1493;&#1488;&#1514;&#1499;&#1500;&#1504;&#1508;&#1513;&#1492;&#1495;&#1497;&#1492;&#1492;&#1512;&#1502;&#1513;&#1514;&#1488;&#1513;&#1512;&#1513;&#1512;&#1510;&#1493;&#1492;&#1502;&#1497;&#1502;&#1500;&#1502;&#1497;&#1504;&#1492;&#1502;&#1493;&#1488;&#1514;&#1499;&#1500;&#1506;&#1493;&#1508;&#1499;&#1504;&#1508;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1489;&#1512;&#1499;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1488;&#1502;&#1512;&#1508;&#1512;&#1493;&#1493;&#1512;&#1489;&#1493;&#1493;&#1502;&#1500;&#1488;&#1493;&#1488;&#1514;&#1492;&#1502;&#1497;&#1502;&#1489;&#1497;&#1502;&#1497;&#1502;&#1493;&#1492;&#1506;&#1493;&#1508;&#1497;&#1512;&#1489;&#1489;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1495;&#1502;&#1497;&#1513;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1514;&#1493;&#1510;&#1488;&#1492;&#1488;&#1512;&#1510;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1489;&#1492;&#1502;&#1492;&#1493;&#1512;&#1502;&#1513;&#1493;&#1495;&#1497;&#1514;&#1493;&#1488;&#1512;&#1510;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1495;&#1497;&#1514;&#1492;&#1488;&#1512;&#1510;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1488;&#1514;&#1492;&#1489;&#1492;&#1502;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1488;&#1514;&#1499;&#1500;&#1512;&#1502;&#1513;&#1492;&#1488;&#1491;&#1502;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1504;&#1506;&#1513;&#1492;&#1488;&#1491;&#1502;&#1489;&#1510;&#1500;&#1502;&#1504;&#1493;&#1499;&#1491;&#1502;&#1493;&#1514;&#1504;&#1493;&#1493;&#1497;&#1512;&#1491;&#1493;&#1489;&#1491;&#1490;&#1514;&#1492;&#1497;&#1502;&#1493;&#1489;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1489;&#1489;&#1492;&#1502;&#1492;&#1493;&#1489;&#1499;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1489;&#1499;&#1500;&#1492;&#1512;&#1502;&#1513;&#1492;&#1512;&#1502;&#1513;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1488;&#1491;&#1502;&#1489;&#1510;&#1500;&#1502;&#1493;&#1489;&#1510;&#1500;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1512;&#1488;&#1488;&#1514;&#1493;&#1494;&#1499;&#1512;&#1493;&#1504;&#1511;&#1489;&#1492;&#1489;&#1512;&#1488;&#1488;&#1514;&#1502;&#1493;&#1497;&#1489;&#1512;&#1499;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1493;&#1497;&#1488;&#1502;&#1512;&#1500;&#1492;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1508;&#1512;&#1493;&#1493;&#1512;&#1489;&#1493;&#1493;&#1502;&#1500;&#1488;&#1493;&#1488;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1499;&#1489;&#1513;&#1492;&#1493;&#1512;&#1491;&#1493;&#1489;&#1491;&#1490;&#1514;&#1492;&#1497;&#1502;&#1493;&#1489;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1489;&#1499;&#1500;&#1495;&#1497;&#1492;&#1492;&#1512;&#1502;&#1513;&#1514;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1492;&#1504;&#1492;&#1504;&#1514;&#1514;&#1497;&#1500;&#1499;&#1502;&#1488;&#1514;&#1499;&#1500;&#1506;&#1513;&#1489;&#1494;&#1512;&#1506;&#1494;&#1512;&#1506;&#1488;&#1513;&#1512;&#1506;&#1500;&#1508;&#1504;&#1497;&#1499;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1488;&#1514;&#1499;&#1500;&#1492;&#1506;&#1510;&#1488;&#1513;&#1512;&#1489;&#1493;&#1508;&#1512;&#1497;&#1506;&#1510;&#1494;&#1512;&#1506;&#1494;&#1512;&#1506;&#1500;&#1499;&#1502;&#1497;&#1492;&#1497;&#1492;&#1500;&#1488;&#1499;&#1500;&#1492;&#1493;&#1500;&#1499;&#1500;&#1495;&#1497;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1499;&#1500;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1500;&#1499;&#1500;&#1512;&#1493;&#1502;&#1513;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1488;&#1513;&#1512;&#1489;&#1493;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1488;&#1514;&#1499;&#1500;&#1497;&#1512;&#1511;&#1506;&#1513;&#1489;&#1500;&#1488;&#1499;&#1500;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1499;&#1500;&#1488;&#1513;&#1512;&#1506;&#1513;&#1492;&#1493;&#1492;&#1504;&#1492;&#1496;&#1493;&#1489;&#1502;&#1488;&#1491;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1492;&#1513;&#1513;&#1497;";
$alephbet= Array("&#1488;", "&#1489;", "&#1490;", "&#1491;", "&#1492;", "&#1493;", "&#1494;", "&#1495;", "&#1496;", "&#1497;", "&#1499;", "&#1500;", "&#1502;", "&#1504;", "&#1505;", "&#1506;", "&#1508;", "&#1510;", "&#1511;", "&#1512;", "&#1513;", "&#1514;", "&#1498;", "&#1501;", "&#1503;", "&#1507;", "&#1509;");
$alphabet= Array("a", "b", "g", "d", "h", "u", "z", "x", "w", "i", "k", "l", "m", "n", "c", "o", "p", "e", "q", "r", "f", "t", "k", "m", "n", "p", "e");
$into_alephbet= Array("&#1488;", "&#1489;", "&#1490;", "&#1491;", "&#1492;", "&#1493;", "&#1494;", "&#1495;", "&#1496;", "&#1497;", "&#1499;", "&#1500;", "&#1502;", "&#1504;", "&#1505;", "&#1506;", "&#1508;", "&#1510;", "&#1511;", "&#1512;", "&#1513;", "&#1514;");
$vm=array("&#1456;", "&#1468;", "&#1461;", "&#1460;", "&#1473;", "&#1430;", "&#1464;", "&#1457;", "&#1465;", "&#1461;", "&#1463;", "&#1473;", "&#1469;", "&#1462;", "&#1443;", "&#1425;", "&#1445;", "&#1445;", "&#1470;", "&#1431;", "&#1433;", "&#1433;", "&#1428;", "&#1428;", "&#1475;", "&#1470;", "&#1431;", "&#1433;", "&#1433;", "&#1428;", "&#1428;", "&#1447;", "&#1435;", "&#1448;", "&#1444;", " &#1472; ", "&#1474;", "&#1454;", "&#1426;", "&#1458;", "&#1458;", "&#1434;", "&#1434;", " &#1436;", "&#1440;", "&#1449;", "&#1436;", "&#1438;", "&#1429;", "&#1441;", "&#1467;", "&#1467;", "&#1459;", "&#1508;  &#1475;");
$chars=Array();
$keyword_letters=Array();
$chars=Array();
$strKeyword=$word;
for($i=0; $i<count($alephbet); $i++){
	$strKeyword=str_replace($alephbet[$i], $alphabet[$i], $strKeyword);
}
$strKeyword=str_replace(" ", "", $strKeyword);
$kw_into_letters=str_split($strKeyword);
for($eng=0; $eng<count($kw_into_letters); $eng++){
	for($heb=0; $heb<count($into_alephbet); $heb++){
		if($alphabet[$heb]==$kw_into_letters[$eng]){
			//$chars[]=$into_alephbet[$heb];
			$chars[]=$kw_into_letters[$eng];
		}
	}
}

echo "Looking for:".implode($chars);
for($i=0; $i<count($vm); $i++){
	$text_of_this_chapter=str_replace($vm[$i], "", $text_of_this_chapter);
}
$text_of_this_chapter=str_replace(" ", "", $text_of_this_chapter);
for($i=0; $i<count($alephbet); $i++){
	$text_of_this_chapter=str_replace($alephbet[$i], $alphabet[$i], $text_of_this_chapter);
}
$str_into_heb_letters=str_split($text_of_this_chapter);
/*
for($i=0; $i<count($alphabet); $i++){
	$str_into_heb_letters=str_replace($alphabet[$i], $alephbet[$i], $str_into_heb_letters);
}
*/
$string=$text_of_this_chapter;
$COLORS=array('red', 'blue');
$string_split=$str_into_heb_letters;//str_split($string);
$strlen=strlen($string);
if($skiprow=="all"){
	$skiprow=$strlen;
}
$instances=array();
$continue=true;
$pos=0;
?>
<table style="float: left; direction: rtl; text-align: left; padding: 5px;">
    <tr>
<?php //<th style="border: 1px solid black;"></th>
for($i=0; $i<$skiprow; $i++){
	$num=$i+1;
	echo "<th style=\\"border: 1px solid black; font-size: 14px;\\">".$num."</th>\
";
}
?>
    </tr>
    <tr>
<?php
while($continue){
	$instance=array();
	foreach($chars as $char){
		//echo $char;
		if(($newPos=strpos($string, $char, $pos)) !== false){
			array_push($instance, $newPos);
			$string=substr_replace($string, '#', $newPos, 1);
			$pos=$newPos;
		}else{
			$continue=false;
			break;
		}
    }
	if(count($instance)==count($chars)){
		array_push($instances, $instance);
		$pos=0;
	}
}
foreach ($instances as $i=>$instance){
	$color="red";//$COLORS[$i];
	foreach($instance as $char){
		$string_split[$char]="<td style=\\"border: 1px solid black; font-weight: bold; color: ".$color.";\\">".$string_split[$char]."</td>\
";
	}
}
foreach($string_split as $i=>$part){
	//echo 'The character at position ', $i, ' is "', $part, '"<br />';
	if (strlen($part) < 3){
		$string_split[$i] = "<td style=\\"border: 1px solid black;\\">".$string_split[$i]."</td>";
	}
	if ($i % $skiprow==0 && $i>0){
		$string_split[$i] = "\
</tr>\
<tr>\
".$string_split[$i];
	}
}

echo implode("", $string_split);
?>
</tr>
</table> 
</body>
</html>

I’m searching the word turh. At the skip of 50 there should be one starting from the 6th letter from the top left. If you test this code about you’ll find this but for some reason it’s not coloring red nor making the find bold in the style.

ScallioXTX, I don’t understand. How different is this from your example that it’s not working?

Ok one last post from me. Using scallioXTX’s solution:

<!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>Bible Code Example</title>
</head>

<body>
<input id="skiprow" type="text" value="50" />
<input id="word" type="text" value="&#1514;&#1493;&#1512;&#1492;" />
<a href="JavaScript: ext='?skiprow='+document.getElementById('skiprow').value+'&word='+document.getElementById('word').value; window.location=ext;">search this</a><br /><br />
<?php
$skiprow=isset($_GET['skiprow']) ? $_GET['skiprow'] : '';
$word=isset($_GET['word']) ? $_GET['word'] : '';

$text_of_this_chapter="&#1489;&#1512;&#1488;&#1513;&#1497;&#1514;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1488;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1492;&#1488;&#1512;&#1510;&#1492;&#1497;&#1514;&#1492;&#1514;&#1492;&#1493;&#1493;&#1489;&#1492;&#1493;&#1493;&#1495;&#1513;&#1499;&#1506;&#1500;&#1508;&#1504;&#1497;&#1514;&#1492;&#1493;&#1502;&#1493;&#1512;&#1493;&#1495;&#1488;&#1500;&#1492;&#1497;&#1502;&#1502;&#1512;&#1495;&#1508;&#1514;&#1506;&#1500;&#1508;&#1504;&#1497;&#1492;&#1502;&#1497;&#1502;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1488;&#1493;&#1512;&#1493;&#1497;&#1492;&#1497;&#1488;&#1493;&#1512;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1488;&#1493;&#1512;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1489;&#1491;&#1500;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1497;&#1504;&#1492;&#1488;&#1493;&#1512;&#1493;&#1489;&#1497;&#1504;&#1492;&#1495;&#1513;&#1499;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1488;&#1493;&#1512;&#1497;&#1493;&#1502;&#1493;&#1500;&#1495;&#1513;&#1499;&#1511;&#1512;&#1488;&#1500;&#1497;&#1500;&#1492;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1488;&#1495;&#1491;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1512;&#1511;&#1497;&#1506;&#1489;&#1514;&#1493;&#1499;&#1492;&#1502;&#1497;&#1502;&#1493;&#1497;&#1492;&#1497;&#1502;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1502;&#1497;&#1502;&#1500;&#1502;&#1497;&#1502;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1512;&#1511;&#1497;&#1506;&#1493;&#1497;&#1489;&#1491;&#1500;&#1489;&#1497;&#1504;&#1492;&#1502;&#1497;&#1502;&#1488;&#1513;&#1512;&#1502;&#1514;&#1495;&#1514;&#1500;&#1512;&#1511;&#1497;&#1506;&#1493;&#1489;&#1497;&#1504;&#1492;&#1502;&#1497;&#1502;&#1488;&#1513;&#1512;&#1502;&#1506;&#1500;&#1500;&#1512;&#1511;&#1497;&#1506;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1512;&#1511;&#1497;&#1506;&#1513;&#1502;&#1497;&#1502;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1513;&#1504;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1511;&#1493;&#1493;&#1492;&#1502;&#1497;&#1502;&#1502;&#1514;&#1495;&#1514;&#1492;&#1513;&#1502;&#1497;&#1502;&#1488;&#1500;&#1502;&#1511;&#1493;&#1502;&#1488;&#1495;&#1491;&#1493;&#1514;&#1512;&#1488;&#1492;&#1492;&#1497;&#1489;&#1513;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1497;&#1489;&#1513;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1502;&#1511;&#1493;&#1492;&#1492;&#1502;&#1497;&#1502;&#1511;&#1512;&#1488;&#1497;&#1502;&#1497;&#1502;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1514;&#1491;&#1513;&#1488;&#1492;&#1488;&#1512;&#1510;&#1491;&#1513;&#1488;&#1506;&#1513;&#1489;&#1502;&#1494;&#1512;&#1497;&#1506;&#1494;&#1512;&#1506;&#1506;&#1510;&#1508;&#1512;&#1497;&#1506;&#1513;&#1492;&#1508;&#1512;&#1497;&#1500;&#1502;&#1497;&#1504;&#1493;&#1488;&#1513;&#1512;&#1494;&#1512;&#1506;&#1493;&#1489;&#1493;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1514;&#1493;&#1510;&#1488;&#1492;&#1488;&#1512;&#1510;&#1491;&#1513;&#1488;&#1506;&#1513;&#1489;&#1502;&#1494;&#1512;&#1497;&#1506;&#1494;&#1512;&#1506;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1506;&#1510;&#1506;&#1513;&#1492;&#1508;&#1512;&#1497;&#1488;&#1513;&#1512;&#1494;&#1512;&#1506;&#1493;&#1489;&#1493;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1513;&#1500;&#1497;&#1513;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1502;&#1488;&#1512;&#1514;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1492;&#1497;&#1493;&#1502;&#1493;&#1489;&#1497;&#1504;&#1492;&#1500;&#1497;&#1500;&#1492;&#1493;&#1492;&#1497;&#1493;&#1500;&#1488;&#1514;&#1514;&#1493;&#1500;&#1502;&#1493;&#1506;&#1491;&#1497;&#1502;&#1493;&#1500;&#1497;&#1502;&#1497;&#1502;&#1493;&#1513;&#1504;&#1497;&#1502;&#1493;&#1492;&#1497;&#1493;&#1500;&#1502;&#1488;&#1493;&#1512;&#1514;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1488;&#1497;&#1512;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1513;&#1504;&#1497;&#1492;&#1502;&#1488;&#1512;&#1514;&#1492;&#1490;&#1491;&#1500;&#1497;&#1502;&#1488;&#1514;&#1492;&#1502;&#1488;&#1493;&#1512;&#1492;&#1490;&#1491;&#1500;&#1500;&#1502;&#1502;&#1513;&#1500;&#1514;&#1492;&#1497;&#1493;&#1502;&#1493;&#1488;&#1514;&#1492;&#1502;&#1488;&#1493;&#1512;&#1492;&#1511;&#1496;&#1504;&#1500;&#1502;&#1502;&#1513;&#1500;&#1514;&#1492;&#1500;&#1497;&#1500;&#1492;&#1493;&#1488;&#1514;&#1492;&#1499;&#1493;&#1499;&#1489;&#1497;&#1502;&#1493;&#1497;&#1514;&#1504;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1488;&#1497;&#1512;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1502;&#1513;&#1500;&#1489;&#1497;&#1493;&#1502;&#1493;&#1489;&#1500;&#1497;&#1500;&#1492;&#1493;&#1500;&#1492;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1492;&#1488;&#1493;&#1512;&#1493;&#1489;&#1497;&#1504;&#1492;&#1495;&#1513;&#1499;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1512;&#1489;&#1497;&#1506;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1513;&#1512;&#1510;&#1493;&#1492;&#1502;&#1497;&#1502;&#1513;&#1512;&#1510;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1493;&#1506;&#1493;&#1508;&#1497;&#1506;&#1493;&#1508;&#1508;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1506;&#1500;&#1508;&#1504;&#1497;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1497;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1514;&#1504;&#1497;&#1504;&#1502;&#1492;&#1490;&#1491;&#1500;&#1497;&#1502;&#1493;&#1488;&#1514;&#1499;&#1500;&#1504;&#1508;&#1513;&#1492;&#1495;&#1497;&#1492;&#1492;&#1512;&#1502;&#1513;&#1514;&#1488;&#1513;&#1512;&#1513;&#1512;&#1510;&#1493;&#1492;&#1502;&#1497;&#1502;&#1500;&#1502;&#1497;&#1504;&#1492;&#1502;&#1493;&#1488;&#1514;&#1499;&#1500;&#1506;&#1493;&#1508;&#1499;&#1504;&#1508;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1489;&#1512;&#1499;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1488;&#1502;&#1512;&#1508;&#1512;&#1493;&#1493;&#1512;&#1489;&#1493;&#1493;&#1502;&#1500;&#1488;&#1493;&#1488;&#1514;&#1492;&#1502;&#1497;&#1502;&#1489;&#1497;&#1502;&#1497;&#1502;&#1493;&#1492;&#1506;&#1493;&#1508;&#1497;&#1512;&#1489;&#1489;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1495;&#1502;&#1497;&#1513;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1514;&#1493;&#1510;&#1488;&#1492;&#1488;&#1512;&#1510;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1489;&#1492;&#1502;&#1492;&#1493;&#1512;&#1502;&#1513;&#1493;&#1495;&#1497;&#1514;&#1493;&#1488;&#1512;&#1510;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1495;&#1497;&#1514;&#1492;&#1488;&#1512;&#1510;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1488;&#1514;&#1492;&#1489;&#1492;&#1502;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1488;&#1514;&#1499;&#1500;&#1512;&#1502;&#1513;&#1492;&#1488;&#1491;&#1502;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1504;&#1506;&#1513;&#1492;&#1488;&#1491;&#1502;&#1489;&#1510;&#1500;&#1502;&#1504;&#1493;&#1499;&#1491;&#1502;&#1493;&#1514;&#1504;&#1493;&#1493;&#1497;&#1512;&#1491;&#1493;&#1489;&#1491;&#1490;&#1514;&#1492;&#1497;&#1502;&#1493;&#1489;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1489;&#1489;&#1492;&#1502;&#1492;&#1493;&#1489;&#1499;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1489;&#1499;&#1500;&#1492;&#1512;&#1502;&#1513;&#1492;&#1512;&#1502;&#1513;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1488;&#1491;&#1502;&#1489;&#1510;&#1500;&#1502;&#1493;&#1489;&#1510;&#1500;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1512;&#1488;&#1488;&#1514;&#1493;&#1494;&#1499;&#1512;&#1493;&#1504;&#1511;&#1489;&#1492;&#1489;&#1512;&#1488;&#1488;&#1514;&#1502;&#1493;&#1497;&#1489;&#1512;&#1499;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1493;&#1497;&#1488;&#1502;&#1512;&#1500;&#1492;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1508;&#1512;&#1493;&#1493;&#1512;&#1489;&#1493;&#1493;&#1502;&#1500;&#1488;&#1493;&#1488;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1499;&#1489;&#1513;&#1492;&#1493;&#1512;&#1491;&#1493;&#1489;&#1491;&#1490;&#1514;&#1492;&#1497;&#1502;&#1493;&#1489;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1489;&#1499;&#1500;&#1495;&#1497;&#1492;&#1492;&#1512;&#1502;&#1513;&#1514;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1492;&#1504;&#1492;&#1504;&#1514;&#1514;&#1497;&#1500;&#1499;&#1502;&#1488;&#1514;&#1499;&#1500;&#1506;&#1513;&#1489;&#1494;&#1512;&#1506;&#1494;&#1512;&#1506;&#1488;&#1513;&#1512;&#1506;&#1500;&#1508;&#1504;&#1497;&#1499;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1488;&#1514;&#1499;&#1500;&#1492;&#1506;&#1510;&#1488;&#1513;&#1512;&#1489;&#1493;&#1508;&#1512;&#1497;&#1506;&#1510;&#1494;&#1512;&#1506;&#1494;&#1512;&#1506;&#1500;&#1499;&#1502;&#1497;&#1492;&#1497;&#1492;&#1500;&#1488;&#1499;&#1500;&#1492;&#1493;&#1500;&#1499;&#1500;&#1495;&#1497;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1499;&#1500;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1500;&#1499;&#1500;&#1512;&#1493;&#1502;&#1513;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1488;&#1513;&#1512;&#1489;&#1493;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1488;&#1514;&#1499;&#1500;&#1497;&#1512;&#1511;&#1506;&#1513;&#1489;&#1500;&#1488;&#1499;&#1500;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1499;&#1500;&#1488;&#1513;&#1512;&#1506;&#1513;&#1492;&#1493;&#1492;&#1504;&#1492;&#1496;&#1493;&#1489;&#1502;&#1488;&#1491;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1492;&#1513;&#1513;&#1497;";
$alephbet= Array("&#1488;", "&#1489;", "&#1490;", "&#1491;", "&#1492;", "&#1493;", "&#1494;", "&#1495;", "&#1496;", "&#1497;", "&#1499;", "&#1500;", "&#1502;", "&#1504;", "&#1505;", "&#1506;", "&#1508;", "&#1510;", "&#1511;", "&#1512;", "&#1513;", "&#1514;", "&#1498;", "&#1501;", "&#1503;", "&#1507;", "&#1509;");
$alphabet= Array("a", "b", "g", "d", "h", "u", "z", "x", "w", "i", "k", "l", "m", "n", "c", "o", "p", "e", "q", "r", "f", "t", "k", "m", "n", "p", "e");
$into_alephbet= Array("&#1488;", "&#1489;", "&#1490;", "&#1491;", "&#1492;", "&#1493;", "&#1494;", "&#1495;", "&#1496;", "&#1497;", "&#1499;", "&#1500;", "&#1502;", "&#1504;", "&#1505;", "&#1506;", "&#1508;", "&#1510;", "&#1511;", "&#1512;", "&#1513;", "&#1514;");
$vm=array("&#1456;", "&#1468;", "&#1461;", "&#1460;", "&#1473;", "&#1430;", "&#1464;", "&#1457;", "&#1465;", "&#1461;", "&#1463;", "&#1473;", "&#1469;", "&#1462;", "&#1443;", "&#1425;", "&#1445;", "&#1445;", "&#1470;", "&#1431;", "&#1433;", "&#1433;", "&#1428;", "&#1428;", "&#1475;", "&#1470;", "&#1431;", "&#1433;", "&#1433;", "&#1428;", "&#1428;", "&#1447;", "&#1435;", "&#1448;", "&#1444;", " &#1472; ", "&#1474;", "&#1454;", "&#1426;", "&#1458;", "&#1458;", "&#1434;", "&#1434;", " &#1436;", "&#1440;", "&#1449;", "&#1436;", "&#1438;", "&#1429;", "&#1441;", "&#1467;", "&#1467;", "&#1459;", "&#1508;  &#1475;");

$keyword_letters=Array();
$chars=Array();
$strKeyword=$word;
for($i=0; $i<count($alephbet); $i++){
	$strKeyword=str_replace($alephbet[$i], $alphabet[$i], $strKeyword);
}
$strKeyword=str_replace(" ", "", $strKeyword);
$kw_into_letters=str_split($strKeyword);
for($eng=0; $eng<count($kw_into_letters); $eng++){
	for($heb=0; $heb<count($into_alephbet); $heb++){
		if($alphabet[$heb]==$kw_into_letters[$eng]){
			//$chars[]=$into_alephbet[$heb];
			$chars[]=$kw_into_letters[$eng];
		}
	}
}
echo "Looking for:".implode($chars);
for($i=0; $i<count($vm); $i++){
	$text_of_this_chapter=str_replace($vm[$i], "", $text_of_this_chapter);
}
$text_of_this_chapter=str_replace(" ", "", $text_of_this_chapter);
for($i=0; $i<count($alephbet); $i++){
	$text_of_this_chapter=str_replace($alephbet[$i], $alphabet[$i], $text_of_this_chapter);
}
$str_into_heb_letters=str_split($text_of_this_chapter);
/*
for($i=0; $i<count($alphabet); $i++){
	$str_into_heb_letters=str_replace($alphabet[$i], $alephbet[$i], $str_into_heb_letters);
}
*/
//$string="abclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyelove";
//$string_split=str_split($string);
//$chars=str_split("love");

$string=$text_of_this_chapter;
$string_split=str_split($string);
$chars=str_split("turh");

$COLORS=array('red', 'blue');
$strlen=strlen($string);
if($skiprow=="all"){
	$skiprow=$strlen;
}
$instances=array();
$continue=true;
$pos=0;
?>
<table style="float: left; direction: rtl; text-align: left; padding: 5px;">
    <tr>
<?php //<th style="border: 1px solid black;"></th>
for($i=0; $i<$skiprow; $i++){
	$num=$i+1;
	echo "<th style=\\"border: 1px solid black; font-size: 14px;\\">".$num."</th>\
";
}
?>
    </tr>
    <tr>
<?php
while($continue){
	$instance=array();
	foreach($chars as $char){
		//echo $char;
		if(($newPos=strpos($string, $char, $pos)) !== false){
			array_push($instance, $newPos);
			$string=substr_replace($string, '#', $newPos, 1);
			$pos=$newPos;
		}else{
			$continue=false;
			break;
		}
    }
	if(count($instance)==count($chars)){
		array_push($instances, $instance);
		$pos=0;
	}
}
foreach ($instances as $i=>$instance){
	$color="red";//$COLORS[$i];
	foreach($instance as $char){
		$string_split[$char]="<td style=\\"border: 1px solid black; font-weight: bold; color: ".$color.";\\">".$string_split[$char]."</td>\
";
	}
}
foreach($string_split as $i=>$part){
	//echo 'The character at position ', $i, ' is "', $part, '"<br />';
	if (strlen($part) == 1){
		$string_split[$i] = "<td style=\\"border: 1px solid black;\\">".$string_split[$i]."</td>";
	}
	if ($i % $skiprow==0 && $i>0){
		$string_split[$i] = "\
</tr>\
<tr>\
".$string_split[$i];
	}
}

echo implode("", $string_split);
?>
</tr>
</table> 
</body>
</html>

Remove the forward slashes and add them to the others and it works fine:

//$string="abclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyelove";
//$string_split=str_split($string);
//$chars=str_split("love");

$string=$text_of_this_chapter;
$string_split=str_split($string);
$chars=str_split("turh");

You’ll find 3 occurrences of the word love: one at the skip of one letter, the second at the skip of 4 letters and another at a skip of 2 letters. Actually I multiplied the pattern to see if sooner or later it’s going to be messed up but not at all. Everything’s good.

But if you test it with the anglicized hebrew letters it doesn’t work!!!
You might want to add an array of $COLORS:

$colors = Array(
"Red",
"Blue",
"Green",
"Orange",
"Pink",
"Sienna",
"DarkOliveGreen",
"DarkGreen",
"DarkSlateBlue",
"Navy",
"Indigo",
"DarkSlateGray",
"DarkRed",
"DarkOrange",
"Olive",
"Teal",
"SlateGray",
"DimGray",
"SandyBrown",
"YellowGreen",
"SeaGreen",
"MediumTurquoise",
"Purple",
"Gray",
"LemonChiffon",
"Magenta",
"Yellow",
"Lime",
"Cyan",
"DeepSkyBlue",
"DarkOrchid",
"Silver",
"PaleTurquoise",
"Wheat",
"PaleGreen",
"LightBlue",
"Plum",
"Black"
);

$COLORS = Array();
for($c=0; $c<count($colors); $c++){
	$COLORS[$c]=strtolower($colors[$c]);
}

edited in:
I think ScallioXTX’s code is faulty. Add an o replacing the x after the first l and the pattern gets messed up. So that’s the problem.

My code doesn’t search for equidistant chars, it does look for repeating patterns. So indeed, it gets stuff wrong.

I’ve refactored your code so it’s a lot more readable:


<?php
header('Content-Type: text/html; charset=UTF-8');

$COLORS = array(
	"red", "blue", "darkgreen"
);
$string = "&#1489;&#1512;&#1488;&#1513;&#1497;&#1514;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1488;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1492;&#1488;&#1512;&#1510;&#1492;&#1497;&#1514;&#1492;&#1514;&#1492;&#1493;&#1493;&#1489;&#1492;&#1493;&#1493;&#1495;&#1513;&#1499;&#1506;&#1500;&#1508;&#1504;&#1497;&#1514;&#1492;&#1493;&#1502;&#1493;&#1512;&#1493;&#1495;&#1488;&#1500;&#1492;&#1497;&#1502;&#1502;&#1512;&#1495;&#1508;&#1514;&#1506;&#1500;&#1508;&#1504;&#1497;&#1492;&#1502;&#1497;&#1502;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1488;&#1493;&#1512;&#1493;&#1497;&#1492;&#1497;&#1488;&#1493;&#1512;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1488;&#1493;&#1512;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1489;&#1491;&#1500;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1497;&#1504;&#1492;&#1488;&#1493;&#1512;&#1493;&#1489;&#1497;&#1504;&#1492;&#1495;&#1513;&#1499;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1488;&#1493;&#1512;&#1497;&#1493;&#1502;&#1493;&#1500;&#1495;&#1513;&#1499;&#1511;&#1512;&#1488;&#1500;&#1497;&#1500;&#1492;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1488;&#1495;&#1491;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1512;&#1511;&#1497;&#1506;&#1489;&#1514;&#1493;&#1499;&#1492;&#1502;&#1497;&#1502;&#1493;&#1497;&#1492;&#1497;&#1502;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1502;&#1497;&#1502;&#1500;&#1502;&#1497;&#1502;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1512;&#1511;&#1497;&#1506;&#1493;&#1497;&#1489;&#1491;&#1500;&#1489;&#1497;&#1504;&#1492;&#1502;&#1497;&#1502;&#1488;&#1513;&#1512;&#1502;&#1514;&#1495;&#1514;&#1500;&#1512;&#1511;&#1497;&#1506;&#1493;&#1489;&#1497;&#1504;&#1492;&#1502;&#1497;&#1502;&#1488;&#1513;&#1512;&#1502;&#1506;&#1500;&#1500;&#1512;&#1511;&#1497;&#1506;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1512;&#1511;&#1497;&#1506;&#1513;&#1502;&#1497;&#1502;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1513;&#1504;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1511;&#1493;&#1493;&#1492;&#1502;&#1497;&#1502;&#1502;&#1514;&#1495;&#1514;&#1492;&#1513;&#1502;&#1497;&#1502;&#1488;&#1500;&#1502;&#1511;&#1493;&#1502;&#1488;&#1495;&#1491;&#1493;&#1514;&#1512;&#1488;&#1492;&#1492;&#1497;&#1489;&#1513;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1511;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1497;&#1489;&#1513;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1502;&#1511;&#1493;&#1492;&#1492;&#1502;&#1497;&#1502;&#1511;&#1512;&#1488;&#1497;&#1502;&#1497;&#1502;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1514;&#1491;&#1513;&#1488;&#1492;&#1488;&#1512;&#1510;&#1491;&#1513;&#1488;&#1506;&#1513;&#1489;&#1502;&#1494;&#1512;&#1497;&#1506;&#1494;&#1512;&#1506;&#1506;&#1510;&#1508;&#1512;&#1497;&#1506;&#1513;&#1492;&#1508;&#1512;&#1497;&#1500;&#1502;&#1497;&#1504;&#1493;&#1488;&#1513;&#1512;&#1494;&#1512;&#1506;&#1493;&#1489;&#1493;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1514;&#1493;&#1510;&#1488;&#1492;&#1488;&#1512;&#1510;&#1491;&#1513;&#1488;&#1506;&#1513;&#1489;&#1502;&#1494;&#1512;&#1497;&#1506;&#1494;&#1512;&#1506;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1506;&#1510;&#1506;&#1513;&#1492;&#1508;&#1512;&#1497;&#1488;&#1513;&#1512;&#1494;&#1512;&#1506;&#1493;&#1489;&#1493;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1513;&#1500;&#1497;&#1513;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1492;&#1497;&#1502;&#1488;&#1512;&#1514;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1492;&#1497;&#1493;&#1502;&#1493;&#1489;&#1497;&#1504;&#1492;&#1500;&#1497;&#1500;&#1492;&#1493;&#1492;&#1497;&#1493;&#1500;&#1488;&#1514;&#1514;&#1493;&#1500;&#1502;&#1493;&#1506;&#1491;&#1497;&#1502;&#1493;&#1500;&#1497;&#1502;&#1497;&#1502;&#1493;&#1513;&#1504;&#1497;&#1502;&#1493;&#1492;&#1497;&#1493;&#1500;&#1502;&#1488;&#1493;&#1512;&#1514;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1488;&#1497;&#1512;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1513;&#1504;&#1497;&#1492;&#1502;&#1488;&#1512;&#1514;&#1492;&#1490;&#1491;&#1500;&#1497;&#1502;&#1488;&#1514;&#1492;&#1502;&#1488;&#1493;&#1512;&#1492;&#1490;&#1491;&#1500;&#1500;&#1502;&#1502;&#1513;&#1500;&#1514;&#1492;&#1497;&#1493;&#1502;&#1493;&#1488;&#1514;&#1492;&#1502;&#1488;&#1493;&#1512;&#1492;&#1511;&#1496;&#1504;&#1500;&#1502;&#1502;&#1513;&#1500;&#1514;&#1492;&#1500;&#1497;&#1500;&#1492;&#1493;&#1488;&#1514;&#1492;&#1499;&#1493;&#1499;&#1489;&#1497;&#1502;&#1493;&#1497;&#1514;&#1504;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1500;&#1492;&#1488;&#1497;&#1512;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1502;&#1513;&#1500;&#1489;&#1497;&#1493;&#1502;&#1493;&#1489;&#1500;&#1497;&#1500;&#1492;&#1493;&#1500;&#1492;&#1489;&#1491;&#1497;&#1500;&#1489;&#1497;&#1504;&#1492;&#1488;&#1493;&#1512;&#1493;&#1489;&#1497;&#1504;&#1492;&#1495;&#1513;&#1499;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1512;&#1489;&#1497;&#1506;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1497;&#1513;&#1512;&#1510;&#1493;&#1492;&#1502;&#1497;&#1502;&#1513;&#1512;&#1510;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1493;&#1506;&#1493;&#1508;&#1497;&#1506;&#1493;&#1508;&#1508;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1506;&#1500;&#1508;&#1504;&#1497;&#1512;&#1511;&#1497;&#1506;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1497;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1514;&#1504;&#1497;&#1504;&#1502;&#1492;&#1490;&#1491;&#1500;&#1497;&#1502;&#1493;&#1488;&#1514;&#1499;&#1500;&#1504;&#1508;&#1513;&#1492;&#1495;&#1497;&#1492;&#1492;&#1512;&#1502;&#1513;&#1514;&#1488;&#1513;&#1512;&#1513;&#1512;&#1510;&#1493;&#1492;&#1502;&#1497;&#1502;&#1500;&#1502;&#1497;&#1504;&#1492;&#1502;&#1493;&#1488;&#1514;&#1499;&#1500;&#1506;&#1493;&#1508;&#1499;&#1504;&#1508;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1489;&#1512;&#1499;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1500;&#1488;&#1502;&#1512;&#1508;&#1512;&#1493;&#1493;&#1512;&#1489;&#1493;&#1493;&#1502;&#1500;&#1488;&#1493;&#1488;&#1514;&#1492;&#1502;&#1497;&#1502;&#1489;&#1497;&#1502;&#1497;&#1502;&#1493;&#1492;&#1506;&#1493;&#1508;&#1497;&#1512;&#1489;&#1489;&#1488;&#1512;&#1510;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1495;&#1502;&#1497;&#1513;&#1497;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1514;&#1493;&#1510;&#1488;&#1492;&#1488;&#1512;&#1510;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1489;&#1492;&#1502;&#1492;&#1493;&#1512;&#1502;&#1513;&#1493;&#1495;&#1497;&#1514;&#1493;&#1488;&#1512;&#1510;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1506;&#1513;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1495;&#1497;&#1514;&#1492;&#1488;&#1512;&#1510;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1488;&#1514;&#1492;&#1489;&#1492;&#1502;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1488;&#1514;&#1499;&#1500;&#1512;&#1502;&#1513;&#1492;&#1488;&#1491;&#1502;&#1492;&#1500;&#1502;&#1497;&#1504;&#1492;&#1493;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1499;&#1497;&#1496;&#1493;&#1489;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1504;&#1506;&#1513;&#1492;&#1488;&#1491;&#1502;&#1489;&#1510;&#1500;&#1502;&#1504;&#1493;&#1499;&#1491;&#1502;&#1493;&#1514;&#1504;&#1493;&#1493;&#1497;&#1512;&#1491;&#1493;&#1489;&#1491;&#1490;&#1514;&#1492;&#1497;&#1502;&#1493;&#1489;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1489;&#1489;&#1492;&#1502;&#1492;&#1493;&#1489;&#1499;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1489;&#1499;&#1500;&#1492;&#1512;&#1502;&#1513;&#1492;&#1512;&#1502;&#1513;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1489;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1492;&#1488;&#1491;&#1502;&#1489;&#1510;&#1500;&#1502;&#1493;&#1489;&#1510;&#1500;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1489;&#1512;&#1488;&#1488;&#1514;&#1493;&#1494;&#1499;&#1512;&#1493;&#1504;&#1511;&#1489;&#1492;&#1489;&#1512;&#1488;&#1488;&#1514;&#1502;&#1493;&#1497;&#1489;&#1512;&#1499;&#1488;&#1514;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1493;&#1497;&#1488;&#1502;&#1512;&#1500;&#1492;&#1502;&#1488;&#1500;&#1492;&#1497;&#1502;&#1508;&#1512;&#1493;&#1493;&#1512;&#1489;&#1493;&#1493;&#1502;&#1500;&#1488;&#1493;&#1488;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1499;&#1489;&#1513;&#1492;&#1493;&#1512;&#1491;&#1493;&#1489;&#1491;&#1490;&#1514;&#1492;&#1497;&#1502;&#1493;&#1489;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1489;&#1499;&#1500;&#1495;&#1497;&#1492;&#1492;&#1512;&#1502;&#1513;&#1514;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1497;&#1488;&#1502;&#1512;&#1488;&#1500;&#1492;&#1497;&#1502;&#1492;&#1504;&#1492;&#1504;&#1514;&#1514;&#1497;&#1500;&#1499;&#1502;&#1488;&#1514;&#1499;&#1500;&#1506;&#1513;&#1489;&#1494;&#1512;&#1506;&#1494;&#1512;&#1506;&#1488;&#1513;&#1512;&#1506;&#1500;&#1508;&#1504;&#1497;&#1499;&#1500;&#1492;&#1488;&#1512;&#1510;&#1493;&#1488;&#1514;&#1499;&#1500;&#1492;&#1506;&#1510;&#1488;&#1513;&#1512;&#1489;&#1493;&#1508;&#1512;&#1497;&#1506;&#1510;&#1494;&#1512;&#1506;&#1494;&#1512;&#1506;&#1500;&#1499;&#1502;&#1497;&#1492;&#1497;&#1492;&#1500;&#1488;&#1499;&#1500;&#1492;&#1493;&#1500;&#1499;&#1500;&#1495;&#1497;&#1514;&#1492;&#1488;&#1512;&#1510;&#1493;&#1500;&#1499;&#1500;&#1506;&#1493;&#1508;&#1492;&#1513;&#1502;&#1497;&#1502;&#1493;&#1500;&#1499;&#1500;&#1512;&#1493;&#1502;&#1513;&#1506;&#1500;&#1492;&#1488;&#1512;&#1510;&#1488;&#1513;&#1512;&#1489;&#1493;&#1504;&#1508;&#1513;&#1495;&#1497;&#1492;&#1488;&#1514;&#1499;&#1500;&#1497;&#1512;&#1511;&#1506;&#1513;&#1489;&#1500;&#1488;&#1499;&#1500;&#1492;&#1493;&#1497;&#1492;&#1497;&#1499;&#1504;&#1493;&#1497;&#1512;&#1488;&#1488;&#1500;&#1492;&#1497;&#1502;&#1488;&#1514;&#1499;&#1500;&#1488;&#1513;&#1512;&#1506;&#1513;&#1492;&#1493;&#1492;&#1504;&#1492;&#1496;&#1493;&#1489;&#1502;&#1488;&#1491;&#1493;&#1497;&#1492;&#1497;&#1506;&#1512;&#1489;&#1493;&#1497;&#1492;&#1497;&#1489;&#1511;&#1512;&#1497;&#1493;&#1502;&#1492;&#1513;&#1513;&#1497;";

$alephbet = array(
	"&#1488;", "&#1489;", "&#1490;", "&#1491;", "&#1492;", "&#1493;", "&#1494;", "&#1495;", "&#1496;", "&#1497;", "&#1499;", "&#1500;", "&#1502;", "&#1504;", "&#1505;", "&#1506;", "&#1508;", "&#1510;", "&#1511;", "&#1512;", "&#1513;", "&#1514;", "&#1498;", "&#1501;", "&#1503;", "&#1507;", "&#1509;"
);
$alphabet = array(
	"a", "b", "g", "d", "h", "u", "z", "x", "w", "i", "k", "l", "m", "n", "c", "o", "p", "e", "q", "r", "f", "t", "k", "m", "n", "p", "e"
);
$translate = array_combine($alephbet, $alphabet);

$into_alephbet = array(
	"&#1488;", "&#1489;", "&#1490;", "&#1491;", "&#1492;", "&#1493;", "&#1494;", "&#1495;", "&#1496;", "&#1497;", "&#1499;", "&#1500;", "&#1502;", "&#1504;", "&#1505;", "&#1506;", "&#1508;", "&#1510;", "&#1511;", "&#1512;", "&#1513;", "&#1514;"
);
$vm = array(
	"&#1456;", "&#1468;", "&#1461;", "&#1460;", "&#1473;", "&#1430;", "&#1464;", "&#1457;", "&#1465;", "&#1461;", "&#1463;", "&#1473;", "&#1469;", "&#1462;", "&#1443;", "&#1425;", "&#1445;", "&#1445;", "&#1470;", "&#1431;", "&#1433;", "&#1433;", "&#1428;", "&#1428;", "&#1475;", "&#1470;", "&#1431;", "&#1433;", "&#1433;", "&#1428;", "&#1428;", "&#1447;", "&#1435;", "&#1448;", "&#1444;", " &#1472; ", "&#1474;", "&#1454;", "&#1426;", "&#1458;", "&#1458;", "&#1434;", "&#1434;", " &#1436;", "&#1440;", "&#1449;", "&#1436;", "&#1438;", "&#1429;", "&#1441;", "&#1467;", "&#1467;", "&#1459;", "&#1508;  &#1475;"
);

$word = isset($_GET['word']) ? $_GET['word'] : '';
$word = str_replace(
	' ',
	'',
	strtr(
		$word,
		$translate
	)
);

$chars = array();
$kw_into_letters = str_split($word);
for ($english = 0; $english < count($kw_into_letters); $english++) {
	for ($hebrew = 0; $hebrew < count($into_alephbet); $hebrew++) {
		if ($alphabet[$hebrew] == $kw_into_letters[$english]) {
			$chars[] = $kw_into_letters[$english];
		}
	}
}

echo 'Looking for', implode($chars), '<br />';

$string = strtr(
	str_replace(
		array_merge($vm, array(' ')),
		array(''),
		$string
	),
	$translate
);

$string_split = str_split($string);

$skiprow = isset($_GET['skiprow']) ? $_GET['skiprow'] : 20;
if ($skiprow == 'all') {
	$skiprow = strlen($string);
}

$instances = array();
$continue = true;
$pos = 0;
?>
<table style="float: left; direction: rtl; text-align: left; padding: 5px;">
	<tr>
		<?php
		for ($i = 0; $i < $skiprow; $i++)
			echo "<th style=\\"border: 1px solid black; font-size: 14px; width: 60px;\\">" . ($i+1) . "</th>\
";
		?>
	</tr>
	<tr>
		<?php
		while ($continue) {
			$instance = array();
			foreach ($chars as $char) {
				if (($newPos = strpos($string, $char, $pos)) !== false) {
					array_push($instance, $newPos);
					$string = substr_replace($string, '#', $newPos, 1);
					$pos = $newPos;
				} else {
					$continue = false;
					break;
				}
			}
			if (count($instance) == count($chars)) {
				array_push($instances, $instance);
				$pos = 0;
			}
		}
		foreach ($instances as $i => $instance) {
			$color = $COLORS[$i % count($COLORS)];
			foreach ($instance as $char) {
				$string_split[$char] = "<td style=\\"border: 1px solid black; font-weight: bold; color: " . $color . ";\\">" . $string_split[$char] . ", <small>$i</small></td>\
";
			}
		}
		foreach ($string_split as $i => $part) {
			if (strlen($part) == 1) {
				$string_split[$i] = "<td style=\\"border: 1px solid black;\\">" . $string_split[$i] . "</td>";
			}
			if ($i % $skiprow == 0 && $i > 0) {
				$string_split[$i] = "\
</tr>\
<tr>\
" . $string_split[$i];
			}
		}
		echo implode("", $string_split);
		?>
	</tr>
</table>

I really don’t get what you’re trying to on line 34 - 42 but I’ll just assume it has something to do with translating hebrew to english.

Anyway, if you want to change the script to search for equidistant characters you need to change this part:


while ($continue) {
	$instance = array();
	foreach ($chars as $char) {
		if (($newPos = strpos($string, $char, $pos)) !== false) {
			array_push($instance, $newPos);
			$string = substr_replace($string, '#', $newPos, 1);
			$pos = $newPos;
		} else {
			$continue = false;
			break;
		}
	}
	if (count($instance) == count($chars)) {
		array_push($instances, $instance);
		$pos = 0;
	}
}

That’s the part that’s actually doing the searching. The rest is display purposes only.

Should the whole thing be in the body section? Since I see the header().

The header is just because my browser didn’t display the hebrew characters correctly. You can remove it if you want.

Ok.

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes) in …\mybcode5.php on line 178

        while ($continue) {

            $instance = array();

            foreach ($chars as $char) {

                if (($newPos = strpos($string, $char, $pos)) !== false) {

                    array_push($instance, $newPos);

                    $string = substr_replace($string, '#', $newPos, 1);

                    $pos = $newPos;

                } else {

                    $continue = false;

                    break;

                }

            }

            if (count($instance) == count($chars)) {

                array_push($instances, $instance);//<---line 178

                $pos = 0;

            }

I think I understand what’s happening. The number helped me find patterns but not what I intend. I think I know how to search now.

First, after the word is broken down into characters, it should search for the first letter throughout all the text.

And then it should search for the 2nd letter and mark the distance and see if the 3rd letter would occur in the same distance, if not, go on to the next possible distance. If, success then, maybe we need an array marking the color in which the result should appear the letters and the position of the letters.
If failure then the search should go on to the next first letter and try the same thing.

Could you be a bit more elaborate about that last post please? An error message without any context (what string did you use, what word were you looking for, have you changed anything since my last post, etc, etc) is rather vague.

Exactly! :Partier:

Never mind because the textboxes which I added later on solved that issue.

What’s wrong with this:

$string="abclxoxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyelove";
$string_split=str_split($string);
$chars=str_split("love");

$first_letter=Array();
$position=Array();

for($i=0; $i<count($string_split); $i++){
	if($chars[0]==$string_split[$i]){
		$first_letter[]=$string_split[$i];
		$position[]=strpos($string, $string_split[$i]);
	}
	
}
print_r($first_letter);
print_r($position);

I keep getting 1s and 3s.
edit:
I stand corrected 1 is actually an L and 3 is the first position. But then how do you find out all the positions?

What is it supposed to do?

Find the positions of the 1st letter of the word (which is the letter l) in the $string.

Your code makes no sense at all. Below is an outline of how to do what you want. Please read it carefully to see if you understand it. Don’t just copy/paste and hope for the best.


$charToSearchFor='l';
$string='lovelovelovelovelove';
$pos=0;
$positions=array();
$continue=true;
while ($continue)
{
   if (false !== ($newPos=strpos($string, $charToSearchFor, $pos)))
   {
      $pos=$newPos+1;
      array_push($positions, $newPos);
   }
   else
   {
      $continue=false;
   }
}
var_dump($positions);
/**
array(5) {
  [0]=>
  int(0)
  [1]=>
  int(4)
  [2]=>
  int(8)
  [3]=>
  int(12)
  [4]=>
  int(16)
}
**/

There are many ways to ‘skin a cat’, so I’ll add one to ScallioXTX’s solution.


<?php
$string = 'lovelovelovelovelove';

$positions = array();

foreach(str_split($string) as $pos => $char){
  if('l' === $char){
    array_push($positions, $pos);
  }
}

var_dump(
  $positions
);

/*
  array(5) {
    [0]=>
    int(0)
    [1]=>
    int(4)
    [2]=>
    int(8)
    [3]=>
    int(12)
    [4]=>
    int(16)
  }
*/

One for fun.


<?php
class CharacterFilter extends FilterIterator{
  protected
    $char;
  
  public function __construct(Iterator $iterator, $char){
    parent::__construct($iterator);
    $this->char = $char;
  }
  
  public function accept(){
    return $this->char === parent::current();
  }
}

$it = new ArrayIterator(
  str_split('lovelovelovelovelove')
);

foreach(new CharacterFilter($it, 'l') as $pos => $char){
  printf("Char '%s' found at position %d\
", $char, $pos);
}

/*
  Char 'l' found at position 0
  Char 'l' found at position 4
  Char 'l' found at position 8
  Char 'l' found at position 12
  Char 'l' found at position 16
*/

First you want to hunt me down and now you want to skin a cat?