View Single Post
  #1 (permalink)  
Old January 26th, 2018, 11:28 PM
gilgalbiblewheel gilgalbiblewheel is offline
Friend of Wrox
Points: 1,107, Level: 13
Points: 1,107, Level: 13 Points: 1,107, Level: 13 Points: 1,107, Level: 13
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: , , .
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default why json_encode( all of a sudden stopped encoding the php arrays

I'm stuck on why json_encode( all of a sudden stopped encoding the php arrays int JavaScript arrays. It shows them empty.

PHP Code:
    $js_data = Array();

    for($i=0;$i<count($newStrongsResult);$i++){
        
        $searchStrongs = "SELECT * FROM ".$dbTable13." WHERE strongs = '".$newStrongsResult[$i]."' AND ";
        $searchStrongs .= "(";
        $searchStrongs .= " (book = '".$getB1."' AND chapter = '".$getC1."') OR ";
        $searchStrongs .= " (book = '".$getB2."' AND chapter = '".$getC2."') ";
        $searchStrongs .= ")";
        $searchStrongsResult = $conn->query($searchStrongs);
        
        while($row = $searchStrongsResult->fetch(PDO::FETCH_ASSOC)) {
            $searchStrongs_id[$i][] = $row['id'];
            $searchStrongs_book[$i][] = $row['book'];        
            $searchStrongs_bookTitle[$i][] = $row['book_title'];
            $searchStrongs_recordType[$i][] = $row['recordType'];        
            $searchStrongs_chapter[$i][] = $row['chapter'];
            $searchStrongs_verse[$i][] = $row['verse'];
            $searchStrongs_bookSpoke[$i][] = $row['book_spoke']; 
            $searchStrongs_chapterSpoke[$i][] = $row['chapter_spoke']; 
            $searchStrongs_verseSpoke[$i][] = $row['verse_spoke'];
            $searchStrongs_textData[$i][] = $row['text_data'];        
            $searchStrongs_strongs[$i][] = $row['strongs'];
            $searchStrongs_transliteration[$i][] = $row['transliteration'];
            $searchStrongs_etymology[$i][] = $row['etymology'];
            $searchStrongs_etymStrongs[$i][] = $row['etym_strongs'];
            $searchStrongs_etymDesc[$i][] = lcfirst($row['etym_desc']);
            $searchStrongs_hebWord[$i][] = hebrevc($row['heb_word']);
            $searchStrongs_added[$i][] = $row['added'];
            $searchStrongs_also[$i][] = $row['also'];
        }
        
        $joinedTextData = "('".implode("', \n'", $searchStrongs_textData[$i])."')\n\n";
        
        $joinedTransliteration = "('".implode("', \n'", $searchStrongs_transliteration[$i])."')\n\n";
        $joinedHebrewword = "('".implode("', \n'", $searchStrongs_hebWord[$i])."')\n\n";
        $joinedStrongs_etymDesc = "('".implode("', '", $searchStrongs_etymDesc[$i])."')\n\n";
        
        $joined_Transliteration_Hebrewword_Strongs_etymDesc = Array();
        
        for($j=0;$j<count($searchStrongs_transliteration);$j++){
            $joined_Transliteration_Hebrewword_Strongs_etymDesc = Array(    
                $searchStrongs_transliteration[$j][0],
                $searchStrongs_hebWord[$j][0],
                $searchStrongs_etymDesc[$j][0]);
        }

        $js_data[] = Array($i, $newStrongsResult[$i], $joinedTextData, count($searchStrongs_textData[$i]), $joined_Transliteration_Hebrewword_Strongs_etymDesc, $searchStrongs_added[0], $searchStrongs_also[0], $colors[$i]);
    }

/**************************************/
<?php /*?>
        $id[] = $row['id'];
        $book[] = $row['book'];        
        $bookTitle[] = $row['book_title'];
        $recordType[] = $row['recordType'];        
        $chapter[] = $row['chapter'];
        $verse[] = $row['verse'];
        $bookSpoke[] = $row['book_spoke']; 
        $chapterSpoke[] = $row['chapter_spoke']; 
        $verseSpoke[] = $row['verse_spoke'];
        $textData[] = $row['text_data'];        
        $strongs[] = $row['strongs'];
        $transliteration[] = $row['transliteration'];
        $etymology[] = $row['etymology'];
        $etymStrongs[] = $row['etym_strongs'];
        $etymDesc[] = lcfirst($row['etym_desc']);
        $hebWord[] = hebrevc($row['heb_word']);
        $added[] = $row['added'];
        $also[] = $row['also'];
<?php */
?>    

var js_text1 = <?php echo json_encode($js_text1); ?>;

var js_text2 = <?php echo json_encode($js_text2); ?>;

<?php /*?> 
    0    $i, 
    1    $newStrongsResult[$i], 
    2    $joinedTextData, 
    3    count($searchStrongs_textData[$i]), 
    4    $joined_Transliteration_Hebrewword_Strongs_etymDesc, 
    5    $searchStrongs_added[0], 
    6    $searchStrongs_also[0], 
    7    $colors[$i]
<?php */
?>

var js_data = <?php echo json_encode($js_data); ?>;

var js_newStrongsResult = [<?php echo '"'.implode('","'$newStrongsResult).'"' ?>]; //$php_array
Reply With Quote