SitePoint Sponsor

User Tag List

Page 4 of 4 FirstFirst 1234
Results 76 to 87 of 87
  1. #76
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,031
    Mentioned
    152 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by gilgalbiblewheel View Post
    ok. How do you search if php.net has such a function? What is it called?
    A good place to start would be the list of string functions
    And of course there is always google.
    Rémon - Hosting Advisor

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  2. #77
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,396
    Mentioned
    61 Post(s)
    Tagged
    0 Thread(s)
    gilgalbiblewheel, am I correct in thinking that you really want to be searching with a hebrew word (not "love") within hebrew text (not "xxlxxoxxvxxexx"), and all of the English letter use is just a big, ugly work-around?
    Salathe
    Software Developer and PHP Manual Author.

  3. #78
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Salathe View Post
    gilgalbiblewheel, am I correct in thinking that you really want to be searching with a hebrew word (not "love") within hebrew text (not "xxlxxoxxvxxexx"), and all of the English letter use is just a big, ugly work-around?
    yes
    Code php:
    <?php
    echo strrev("Hello world!"); // outputs "!dlrow olleH"
    ?>
    Compare bible texts (and other tools):
    TheWheelofGod

  4. #79
    SitePoint Zealot Amit Yaron's Avatar
    Join Date
    Jan 2011
    Location
    Hod Haharon, Israel
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want to deal with the Hebrew letters of the string, use the function iconv. The description is found in 'Human Language and Character Encoding Support'.
    The character set for Hebrew is "ISO-8859-8".
    When you want to display your converted Hebrew text, to convert it back to "UTF-8".

  5. #80
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,396
    Mentioned
    61 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gilgalbiblewheel View Post
    yes
    Code php:
    <?php
    echo strrev("Hello world!"); // outputs "!dlrow olleH"
    ?>
    I'm not sure why you posted that code (it has nothing to do with my question) so here is another question for you.

    Can you post an example (or multiple) of the string that needs to be searched, and some example search strings (I could make these up but best to make use of something that you will be using)? Because some text is RTL shouldn't be cause for the kind of workarounds shown in this thread (though, it may be necessary depending on your needs).
    Salathe
    Software Developer and PHP Manual Author.

  6. #81
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Salathe View Post
    I'm not sure why you posted that code (it has nothing to do with my question) so here is another question for you.

    Can you post an example (or multiple) of the string that needs to be searched, and some example search strings (I could make these up but best to make use of something that you will be using)? Because some text is RTL shouldn't be cause for the kind of workarounds shown in this thread (though, it may be necessary depending on your needs).
    My questions were answered. It's just that I have to put together making the code work for the hebrew text. This is the code I'm working on. I probably don't need all this complication. What it's meant to do is take the hebrew text convert it to english letters, take out the vowel marks and punctuations and spaces and paragraph-dividing letters:
    Code PHP:
    $skiprow=isset($_GET['skiprow']) ? $_GET['skiprow'] : '';
    $word=isset($_GET['word']) ? $_GET['word'] : '';
     
    $text_of_this_chapter="בראשיתבראאלהימאתהשמימואתהארצוהארצהיתהתהוובהווחשכעלפניתהומורוחאלהיממרחפתעלפניהמימויאמראלהימיהיאורויהיאורויראאלהימאתהאורכיטובויבדלאלהימבינהאורובינהחשכויקראאלהימלאוריומולחשכקראלילהויהיערבויהיבקריומאחדויאמראלהימיהירקיעבתוכהמימויהימבדילבינמימלמימויעשאלהימאתהרקיעויבדלבינהמימאשרמתחתלרקיעובינהמימאשרמעללרקיעויהיכנויקראאלהימלרקיעשמימויהיערבויהיבקריומשניויאמראלהימיקווהמיממתחתהשמימאלמקומאחדותראההיבשהויהיכנויקראאלהימליבשהארצולמקוההמימקראימימויראאלהימכיטובויאמראלהימתדשאהארצדשאעשבמזריעזרעעצפריעשהפרילמינואשרזרעובועלהארצויהיכנותוצאהארצדשאעשבמזריעזרעלמינהוועצעשהפריאשרזרעובולמינהוויראאלהימכיטובויהיערבויהיבקריומשלישיויאמראלהימיהימארתברקיעהשמימלהבדילבינהיומובינהלילהוהיולאתתולמועדימולימימושנימוהיולמאורתברקיעהשמימלהאירעלהארצויהיכנויעשאלהימאתשניהמארתהגדלימאתהמאורהגדללממשלתהיומואתהמאורהקטנלממשלתהלילהואתהכוכבימויתנאתמאלהימברקיעהשמימלהאירעלהארצולמשלביומובלילהולהבדילבינהאורובינהחשכויראאלהימכיטובויהיערבויהיבקריומרביעיויאמראלהימישרצוהמימשרצנפשחיהועופיעופפעלהארצעלפנירקיעהשמימויבראאלהימאתהתנינמהגדלימואתכלנפשהחיההרמשתאשרשרצוהמימלמינהמואתכלעופכנפלמינהוויראאלהימכיטובויברכאתמאלהימלאמרפרוורבוומלאואתהמימבימימוהעופירבבארצויהיערבויהיבקריומחמישיויאמראלהימתוצאהארצנפשחיהלמינהבהמהורמשוחיתוארצלמינהויהיכנויעשאלהימאתחיתהארצלמינהואתהבהמהלמינהואתכלרמשהאדמהלמינהוויראאלהימכיטובויאמראלהימנעשהאדמבצלמנוכדמותנווירדובדגתהימובעופהשמימובבהמהובכלהארצובכלהרמשהרמשעלהארצויבראאלהימאתהאדמבצלמובצלמאלהימבראאתוזכרונקבהבראאתמויברכאתמאלהימויאמרלהמאלהימפרוורבוומלאואתהארצוכבשהורדובדגתהימובעופהשמימובכלחיההרמשתעלהארצויאמראלהימהנהנתתילכמאתכלעשבזרעזרעאשרעלפניכלהארצואתכלהעצאשרבופריעצזרעזרעלכמיהיהלאכלהולכלחיתהארצולכלעופהשמימולכלרומשעלהארצאשרבונפשחיהאתכלירקעשבלאכלהויהיכנויראאלהימאתכלאשרעשהוהנהטובמאדויהיערבויהיבקריומהששי";
    $alephbet= Array("א", "ב", "ג", "ד", "ה", "ו", "ז", "ח", "ט", "י", "כ", "ל", "מ", "נ", "ס", "ע", "פ", "צ", "ק", "ר", "ש", "ת", "ך", "ם", "ן", "ף", "ץ");
    $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("א", "ב", "ג", "ד", "ה", "ו", "ז", "ח", "ט", "י", "כ", "ל", "מ", "נ", "ס", "ע", "פ", "צ", "ק", "ר", "ש", "ת");
    $vm=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;//"lovelovelovelove";
    $word     = "alhimbra";
    $matches  = array();
    echo $string;
    for($pos = 0; $pos < strlen($string); $pos++){
    	if($word[0] !== $string[$pos]){
    		continue;
    	}
    	for($distance = 1; ($pos + $distance) < strlen($string); $distance++){
    		if($word[1] !== $string[$pos + $distance]){
    			continue;
    		}
    		$search = '';
    		for($i = 0; $i < strlen($word); $i++){
    			$search .= isset($string[$pos + ($i * $distance)]) ? $string[$pos + ($i * $distance)] : '' ;
    		}
    		if($word === $search){
    			$match = array();
    			for($i = 0; $i < strlen($word); $i++){
    				$match[$string[$pos + ($i * $distance)]] = $pos + ($i * $distance) ;
    			}
    			array_push($matches, $match);
    		}
    	}
    }
     
    $word = strrev($word );
    for($pos = 0; $pos < strlen($string); $pos++){
    	if($word[0] !== $string[$pos]){
    		continue;
    	}
    	for($distance = 1; ($pos + $distance) < strlen($string); $distance++){
    		if($word[1] !== $string[$pos + $distance]){
    			continue;
    		}
    		$search = '';
    		for($i = 0; $i < strlen($word); $i++){
    			$search .= isset($string[$pos + ($i * $distance)]) ? $string[$pos + ($i * $distance)] : '' ;
    		}
    		if($word === $search){
    			$match = array();
    			for($i = 0; $i < strlen($word); $i++){
    				$match[$string[$pos + ($i * $distance)]] = $pos + ($i * $distance) ;
    			}
    			array_push($matches, $match);
    		}
    	}
    }
    print_r($matches);
    Compare bible texts (and other tools):
    TheWheelofGod

  7. #82
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AnthonySterling View Post
    Looking good!

    How about something like.
    PHP Code:
    <?php
    $string  
    'abclxoxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvx';
    $string .= 'xleoyvyeloveabclxxxoxxxvxxleoyvyeloveabclxxxoxxxvxxleoyvyelovee';

    $occurrences = array();

    $word 'love';

    foreach(
    str_split($string) as $pos => $chr){
      if(
    $word[0] !== $chr){
        continue;
      }
      if(
    $word === substr($string$posstrlen($word))){
        
    $occurrences[$pos] = array();
        for(
    $i 0$i strlen($word); $i++){
          
    $occurrences[$pos][ $word[$i] ] = $pos $i;
        }
      }
    }

    var_dump(
      
    $occurrences
    );

    /*
      array(5) {
        [21]=>
        array(4) {
          ["l"]=>
          int(21)
          ["o"]=>
          int(22)
          ["v"]=>
          int(23)
          ["e"]=>
          int(24)
        }
        [46]=>
        array(4) {
          ["l"]=>
          int(46)
          ["o"]=>
          int(47)
          ["v"]=>
          int(48)
          ["e"]=>
          int(49)
        }
        [71]=>
        array(4) {
          ["l"]=>
          int(71)
          ["o"]=>
          int(72)
          ["v"]=>
          int(73)
          ["e"]=>
          int(74)
        }
        [96]=>
        array(4) {
          ["l"]=>
          int(96)
          ["o"]=>
          int(97)
          ["v"]=>
          int(98)
          ["e"]=>
          int(99)
        }
        [121]=>
        array(4) {
          ["l"]=>
          int(121)
          ["o"]=>
          int(122)
          ["v"]=>
          int(123)
          ["e"]=>
          int(124)
        }
      }
    */
    how can I put $occurrences back in a for or foreach loop (preferrably the latter.) Because I'm not used to seeing letters in a [], but numbers.
    I'm trying to figure out how to put it in here:
    Code php:
    include("colors.php");//$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>\n";
    }
    ?>
        </tr>
        <tr>
    <?php
    while($continue){
    	$instance=array();
    	//foreach($chars as $char){
    	foreach($matches as $match){
    		//echo $char;
    		if(($newPos=strpos($string, $match, $pos)) !== false){
    			array_push($instance, $newPos);
    			$string=substr_replace($string, '#', $newPos, 1);
    			$pos=$newPos;
    		}else{
    			$continue=false;
    			break;
    		}
        }
    	if(count($instance)==count($matches)){
    		array_push($instances, $instance);
    		$pos=0;
    	}
    }
    foreach ($instances as $i=>$instance){
    	$color=$COLORS[$i];
    	foreach($instance as $match){
    		$string_split[$match]="<td style=\"border: 1px solid black; font-weight: bold; color: ".$color.";\">".$string_split[$match]."</td>\n";
    	}
    }
    Compare bible texts (and other tools):
    TheWheelofGod

  8. #83
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Amit Yaron View Post
    If you want to deal with the Hebrew letters of the string, use the function iconv. The description is found in 'Human Language and Character Encoding Support'.
    The character set for Hebrew is "ISO-8859-8".
    When you want to display your converted Hebrew text, to convert it back to "UTF-8".
    Amit you're probably the right person to answer this. The split() is giving problems when it comes to splitting hebrew text. It's showing a diamond with a ? within the diamond. Because of this I had to convert it to English first and then split it and reconvert to hebrew. Isn't there another function which would make the task easier?
    Compare bible texts (and other tools):
    TheWheelofGod

  9. #84
    SitePoint Zealot Amit Yaron's Avatar
    Join Date
    Jan 2011
    Location
    Hod Haharon, Israel
    Posts
    107
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by gilgalbiblewheel View Post
    Amit you're probably the right person to answer this. The split() is giving problems when it comes to splitting hebrew text. It's showing a diamond with a ? within the diamond. Because of this I had to convert it to English first and then split it and reconvert to hebrew. Isn't there another function which would make the task easier?
    I don't know of any, and the Hebrew letter set and pointing, makes such text processing more complicated. My suggestion is to make all the text processing in ISO-8859-8, because the CPU reads bits and bytes, and convert back to UTF-8 just before you render the text.

  10. #85
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
    <?php 
    $text_of_this_chapter_heb="בראשיתבראאלהימאתהשמימואתהארצוהארצהיתהתהוובהווחשכעלפניתהומורוחאלהיממרחפתעלפניהמימויאמראלהימיהיאורויהיאורויראאלהימאתהאורכיטובויבדלאלהימבינהאורובינהחשכויקראאלהימלאוריומולחשכקראלילהויהיערבויהיבקריומאחדויאמראלהימיהירקיעבתוכהמימויהימבדילבינמימלמימויעשאלהימאתהרקיעויבדלבינהמימאשרמתחתלרקיעובינהמימאשרמעללרקיעויהיכנויקראאלהימלרקיעשמימויהיערבויהיבקריומשניויאמראלהימיקווהמיממתחתהשמימאלמקומאחדותראההיבשהויהיכנויקראאלהימליבשהארצולמקוההמימקראימימויראאלהימכיטובויאמראלהימתדשאהארצדשאעשבמזריעזרעעצפריעשהפרילמינואשרזרעובועלהארצויהיכנותוצאהארצדשאעשבמזריעזרעלמינהוועצעשהפריאשרזרעובולמינהוויראאלהימכיטובויהיערבויהיבקריומשלישיויאמראלהימיהימארתברקיעהשמימלהבדילבינהיומובינהלילהוהיולאתתולמועדימולימימושנימוהיולמאורתברקיעהשמימלהאירעלהארצויהיכנויעשאלהימאתשניהמארתהגדלימאתהמאורהגדללממשלתהיומואתהמאורהקטנלממשלתהלילהואתהכוכבימויתנאתמאלהימברקיעהשמימלהאירעלהארצולמשלביומובלילהולהבדילבינהאורובינהחשכויראאלהימכיטובויהיערבויהיבקריומרביעיויאמראלהימישרצוהמימשרצנפשחיהועופיעופפעלהארצעלפנירקיעהשמימויבראאלהימאתהתנינמהגדלימואתכלנפשהחיההרמשתאשרשרצוהמימלמינהמואתכלעופכנפלמינהוויראאלהימכיטובויברכאתמאלהימלאמרפרוורבוומלאואתהמימבימימוהעופירבבארצויהיערבויהיבקריומחמישיויאמראלהימתוצאהארצנפשחיהלמינהבהמהורמשוחיתוארצלמינהויהיכנויעשאלהימאתחיתהארצלמינהואתהבהמהלמינהואתכלרמשהאדמהלמינהוויראאלהימכיטובויאמראלהימנעשהאדמבצלמנוכדמותנווירדובדגתהימובעופהשמימובבהמהובכלהארצובכלהרמשהרמשעלהארצויבראאלהימאתהאדמבצלמובצלמאלהימבראאתוזכרונקבהבראאתמויברכאתמאלהימויאמרלהמאלהימפרוורבוומלאואתהארצוכבשהורדובדגתהימובעופהשמימובכלחיההרמשתעלהארצויאמראלהימהנהנתתילכמאתכלעשבזרעזרעאשרעלפניכלהארצואתכלהעצאשרבופריעצזרעזרעלכמיהיהלאכלהולכלחיתהארצולכלעופהשמימולכלרומשעלהארצאשרבונפשחיהאתכלירקעשבלאכלהויהיכנויראאלהימאתכלאשרעשהוהנהטובמאדויהיערבויהיבקריומהששי";
    $alephbet= Array("א", "ב", "ג", "ד", "ה", "ו", "ז", "ח", "ט", "י", "כ", "ל", "מ", "נ", "ס", "ע", "פ", "צ", "ק", "ר", "ש", "ת", "ך", "ם", "ן", "ף", "ץ");
    $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");
    $back_to_alephbet= Array("א", "ב", "ג", "ד", "ה", "ו", "ז", "ח", "ט", "י", "כ", "ל", "מ", "נ", "ס", "ע", "פ", "צ", "ק", "ר", "ש", "ת");
    $vm=array("ְ", "ּ", "ֵ", "ִ", "ׁ", "֖", "ָ", "ֱ", "ֹ", "ֵ", "ַ", "ׁ", "ֽ", "ֶ", "֣", "֑", "֥", "֥", "־", "֗", "֙", "֙", "֔", "֔", "׃", "־", "֗", "֙", "֙", "֔", "֔", "֧", "֛", "֨", "֤", " ׀ ", "ׂ", "֮", "֒", "ֲ", "ֲ", "֚", "֚", " ֜", "֠", "֩", "֜", "֞", "֕", "֡", "ֻ", "ֻ", "ֳ", "פ  ׃");
    ?>
    <!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="תורה" />
    <a href="JavaScript: ext='?skiprow='+document.getElementById('skiprow').value+'&word='+document.getElementById('word').value; window.location=ext;">search this</a><br /><br />
     
    <div style="display: block; width: 300px; border: 1px solid black; overflow-x: hidden; direction: rtl; overflow-y: auto;"><?php echo $text_of_this_chapter_heb;?></div>
    <?php
    /**************************************************************/
    $skiprow=isset($_GET['skiprow']) ? $_GET['skiprow'] : '';
    $word=isset($_GET['word']) ? $_GET['word'] : '';
     
    //transpose keyword into English
    for($i=0; $i<count($alephbet); $i++){
    	$word=str_replace($alephbet[$i], $alphabet[$i], $word);
    }
    $english_word=str_replace(" ", "", $word);
    $reverse_word=strrev(str_replace(" ", "", $word));
    $hebrew_chars=Array();
    $reverse_hebrew_chars=Array();
    //transpose keyword back to Hebrew
    for($eng=0; $eng<strlen($english_word); $eng++){
    	for($heb=0; $heb<count($back_to_alephbet); $heb++){
    		if($alphabet[$heb]==$english_word[$eng]){
    			$hebrew_chars[]=$back_to_alephbet[$heb];
    		}
    		if($alphabet[$heb]==$reverse_word[$eng]){
    			$reverse_hebrew_chars[]=$back_to_alephbet[$heb];
    		}
    	}
    }
    //print_r($hebrew_chars);
    echo "Looking for: ".implode($hebrew_chars)." and ".implode($reverse_hebrew_chars)." (reversed)";
    /**************************************************************/
    for($i=0; $i<count($vm); $i++){
    	$text_of_this_chapter_heb=str_replace($vm[$i], "", $text_of_this_chapter_heb);
    }
     
    $text_of_this_chapter_heb=str_replace(" ", "", $text_of_this_chapter_heb);
    $text_of_this_chapter=$text_of_this_chapter_heb;
    //transpose text into English
    for($i=0; $i<count($alephbet); $i++){
    	$text_of_this_chapter=str_replace($alephbet[$i], $alphabet[$i], $text_of_this_chapter);
    }
    $english_text=$text_of_this_chapter;
     
    $str_into_heb_letters=str_split($text_of_this_chapter);
     
    for($i=0; $i<count($alphabet); $i++){
    	$text_of_this_chapter=str_replace($alphabet[$i], $alephbet[$i], $text_of_this_chapter);
    	//$str_into_heb_letters=str_replace($alphabet[$i], $alephbet[$i], $str_into_heb_letters);
    }
     
    $string=$text_of_this_chapter;//hebrew text
    //echo ">>".$hebrew_chars[0]."<<";
    $string_split=$str_into_heb_letters;
    $matches  = array();
    for($pos = 0; $pos < strlen($string); $pos++){
    	if($hebrew_chars[0] !== $string[$pos]){
    		continue;
    	}
    	for($distance = 1; ($pos + $distance) < strlen($string); $distance++){
    		if($hebrew_chars[1] !== $string[$pos + $distance]){
    			continue;
    		}
    		$search = '';
    		for($i = 0; $i < strlen($hebrew_chars); $i++){
    			$search .= isset($string[$pos + ($i * $distance)]) ? $string[$pos + ($i * $distance)] : '' ;
    		}
    		if($word === $search){
    			$match = array();
    			for($i = 0; $i < strlen($hebrew_chars); $i++){
    				$match[$string[$pos + ($i * $distance)]] = $pos + ($i * $distance) ;
    			}
    			array_push($matches, $match);
    		}
    	}
    }
     
     
    echo "<br />english word = ".$english_word."<< ";
    for($pos = 0; $pos < strlen($english_text); $pos++){
    	if($english_word[0] !== $english_text[$pos]){
    		continue;
    	}
    	for($distance = 1; ($pos + $distance) < strlen($english_text); $distance++){
    		if($english_word[1] !== $english_text[$pos + $distance]){
    			continue;
    		}
    		$search = '';
    		for($i = 0; $i < strlen($english_word); $i++){
    			$search .= isset($english_text[$pos + ($i * $distance)]) ? $english_text[$pos + ($i * $distance)] : '' ;
    		}
    		if($english_word === $search){
    			$match = array();
    			for($i = 0; $i < strlen($english_word); $i++){
    				$match[$english_text[$pos + ($i * $distance)]] = $pos + ($i * $distance) ;
    			}
    			array_push($matches, $match);
    		}
    	}
    }
    include("colors.php");//$COLORS=array('red', 'blue');
    //var_dump($matches);
    print_r($english_text);
    $style=Array();
    $td=Array();
    $tdid=Array();
    $class=Array();
    $result=Array();
    $skip=Array();
    for($i=0; $i<strlen($english_text); $i++){
    	for($j=0;$j<count($matches);$j++){
    		for($k=0;$k<count($matches[$j]);$k++){
    			if($i==0 && $k==0){
    				echo "<br /><strong>matches".$j."=</strong>";
    				print_r($matches[$j]);
    				$style[]="font-weight: bold; color: ".$COLORS[$j]."; ";
    				$tdid[]="td_".$matches[$j][$english_word[$k]];
    				$class[]=$english_word."_".$j;
    				$result[]=$english_word[$k];
    			}
    			if($i==0 && $k==1){
    				$skip[]=$matches[$j][$english_word[$k]] - $matches[$j][$english_word[$k-1]];
    			}
    			if($i==$matches[$j][$english_word[$k]] && $matches[$j-1][$english_word[$k]]!==$matches[$j][$english_word[$k]]){
    				$td[]="<td id=\"".$tdid[$j]."\" class=\"".$class[$j]."\" style=\"border: 1px solid black; ".$style[$j]."\">".$english_word[$k]."</td>";
    				//echo "<br />Position: ".$matches[$j][$english_word[$k]]." letter: ".$result[$j];
    				//$i++;
    			}else{
    				if($j==0 && $k==0){// && $matches[$j-1][$english_word[$k]]!==$matches[$j][$english_word[$k]]
    					if($i!==$matches[$j][$english_word[$k]]){
    						//echo $matches[$j][$english_word[$k]].", ";
    						$td[]="<td id=\"td_".$i."\" style=\"border: 1px solid black; \">".$english_text[$i]."</td>";
    					}
    				}
    			}
    		}
    	}
    }
    //print_r($style);
    //print_r($td);
    //print_r($tdid);
    print_r($skip);
    ?>
    <table style="float: left; direction: rtl; text-align: left; padding: 5px;">
    	<tr>
    <?php
    for($i=0; $i<$skiprow; $i++){
    	$num=$i+1;
    	echo "<th style=\"border: 1px solid black; font-size: 14px;\">".$num."</th>\n";
    }
    ?>
    	</tr>
    	<tr>
    <?php
    for($i=0; $i<count($td); $i++){
    	echo $td[$i]."\n";
    	if ($i % $skiprow==0 && $i>0){
    		echo "\n</tr>\n<tr>\n";
    	}
    }
    ?>
    	</tr>
    </table> 
    </body>
    </html>
    There's a problem in the for loops. Some letters are repeated when they're highlighted:
    Code HTML4Strict:
    <td id="td_31" style="border: 1px solid black; ">r</td>
    <td id="td_32" style="border: 1px solid black; ">e</td>
    <td id="td_33" style="border: 1px solid black; ">h</td>
    <td id="td_34" style="border: 1px solid black; ">i</td>
     
    <td id="td_35" style="border: 1px solid black; ">t</td>
    <td id="td_35" class="turh_3" style="border: 1px solid black; font-weight: bold; color: orange; ">t</td>
    <td id="td_36" style="border: 1px solid black; ">h</td>
    <td id="td_37" style="border: 1px solid black; ">t</td>
    <td id="td_37" class="turh_4" style="border: 1px solid black; font-weight: bold; color: pink; ">t</td>
    <td id="td_38" style="border: 1px solid black; ">h</td>
    <td id="td_39" style="border: 1px solid black; ">u</td>
    <td id="td_40" style="border: 1px solid black; ">u</td>
    I can't figure out how to fix this. If I make a small change the browser crashes. I want the
    Code php:
    				if($j==0 && $k==0){// && $matches[$j-1][$english_word[$k]]!==$matches[$j][$english_word[$k]]
    					if($i!==$matches[$j][$english_word[$k]]){
    						//echo $matches[$j][$english_word[$k]].", ";
    						$td[]="<td id=\"td_".$i."\" style=\"border: 1px solid black; \">".$english_text[$i]."</td>";
    					}
    				}
    			}
    To skip printing the $english_text[$i] when these positions are mentioned:
    matches0=Array ( [t] => 5 [u] => 55 [r] => 105 [h] => 155 )
    matches1=Array ( [t] => 5 [u] => 138 [r] => 271 [h] => 404 )
    matches2=Array ( [t] => 5 [u] => 559 [r] => 1113 [h] => 1667 )
    matches3=Array ( [t] => 35 [u] => 543 [r] => 1051 [h] => 1559 )
    matches4=Array ( [t] => 37 [u] => 94 [r] => 151 [h] => 208 )
    matches5=Array ( [t] => 37 [u] => 432 [r] => 827 [h] => 1222 )
    matches6=Array ( [t] => 275 [u] => 415 [r] => 555 [h] => 695 )
    matches7=Array ( [t] => 364 [u] => 683 [r] => 1002 [h] => 1321 )
    matches8=Array ( [t] => 366 [u] => 644 [r] => 922 [h] => 1200 )
    matches9=Array ( [t] => 366 [u] => 664 [r] => 962 [h] => 1260 )
    matches10=Array ( [t] => 366 [u] => 761 [r] => 1156 [h] => 1551 )
    matches11=Array ( [t] => 516 [u] => 836 [r] => 1156 [h] => 1476 )
    matches12=Array ( [t] => 659 [u] => 675 [r] => 691 [h] => 707 )
    matches13=Array ( [t] => 689 [u] => 791 [r] => 893 [h] => 995 )
    matches14=Array ( [t] => 727 [u] => 916 [r] => 1105 [h] => 1294 )
    matches15=Array ( [t] => 735 [u] => 1023 [r] => 1311 [h] => 1599 )
    matches16=Array ( [t] => 780 [u] => 959 [r] => 1138 [h] => 1317 )
    matches17=Array ( [t] => 788 [u] => 895 [r] => 1002 [h] => 1109 )
    matches18=Array ( [t] => 798 [u] => 932 [r] => 1066 [h] => 1200 )
    matches19=Array ( [t] => 970 [u] => 1048 [r] => 1126 [h] => 1204 )
    Compare bible texts (and other tools):
    TheWheelofGod

  11. #86
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code PHP:
    $chars=$hebrew_chars;
    $string_split=$back_to_hebrew;
    $instances=array();
    $continue=true;
    $pos=0;
    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){
    	$num=$i+1;
    	$color=$COLORS[$i];
    	foreach($instance as $char){
    		$string_split[$char]="<td style=\"border: 1px solid black; font-weight: bold; color: ".$color.";\"><span id=\"span_".$num."\" style=\"display: block; width: 20px; height: 20px; font-weight: bold; font-size: 14px; text-align: center; background-color: ".$color."; color: white;\">".$string_split[$char]."</span></td>\n";
    	}
    }
    foreach($string_split as $i=>$part){
    	$num=$i+1;
    	//echo 'The character at position ', $i, ' is "', $part, '"<br />';
    	if (strlen($part) <3){
    		$string_split[$i] = "<td style=\"border: 1px solid black;\"><span id=\"span_".$num."\" style=\"display: block; width: 20px; height: 20px; font-weight: bold; font-size: 14px; text-align: center; \">".$string_split[$i]."</span></td>";
    	}
    	if ($i % $skiprow==0 && $i>0){
    		$string_split[$i] = "\n</tr>\n<tr>\n".$string_split[$i];
    	}
    }
     
    echo implode("", $string_split);
    I wonder where the changes should be made if an array of position numbers is already determined/figured out before hand?
    I have a short example of the array:
    PHP Code:
    $set=(2705,2726,2747,2768,5,55,105,155,5,138,271,404
    of the word "turh". Since love is 4 characters long this mean the array can be divided into 3 sets of 4. There are some numbers which are repeated. I want the 3 sets to be colored differently.

    I would figure that the $set is somehow similar to $instances except that $set is presenting all in one array and $instances is an array of arrays. If this is fixed it should work.
    Compare bible texts (and other tools):
    TheWheelofGod

  12. #87
    SitePoint Guru
    Join Date
    Aug 2004
    Location
    Canada
    Posts
    730
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://www.gbgrafix.com/thewheelofgo...=1&tochapter=2

    column 6 from the right shows an empty blue td and a red td after that. It's supposed to be the same td. How can I fix that? It doesn't matter the color in this case because this shows the same letter is found in more than 1 combination.

    PHP Code:
    foreach ($instances as $i=>$instance){
        
    $num=$i+1;
        
    $color=$COLORS[$i];
        foreach(
    $instance as $char){
            
    $string_split[$char]="<td style=\"border: 1px solid black; font-weight: bold; color: ".$color.";\"><span id=\"span_".$num."\" style=\"display: block; width: 20px; height: 20px; font-weight: bold; font-size: 14px; text-align: center; background-color: ".$color."; color: white;\">".$string_split[$char]."</span></td>\n";
        }
    }

    foreach(
    $string_split as $i=>$part){
        
    $num=$i+1;
        
    //echo 'The character at position ', $i, ' is "', $part, '"<br />';
        
    if (strlen($part) <3){
            
    $string_split[$i] = "<td style=\"border: 1px solid black;\"><span id=\"span_".$num."\" style=\"display: block; width: 20px; height: 20px; font-weight: bold; font-size: 14px; text-align: center; \">".$string_split[$i]."</span></td>";
        }
        if (
    $i $skiprow==&& $i>0){
            
    $string_split[$i] = "\n</tr>\n<tr>\n".$string_split[$i];
        }
    }

    echo 
    implode(""$string_split); 
    Compare bible texts (and other tools):
    TheWheelofGod


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •