$ovalue){ $nkeys = array_keys($new, $ovalue); foreach($nkeys as $nindex){ $matrix[$oindex][$nindex] = isset($matrix[$oindex - 1][$nindex - 1]) ? $matrix[$oindex - 1][$nindex - 1] + 1 : 1; if($matrix[$oindex][$nindex] > $maxlen){ $maxlen = $matrix[$oindex][$nindex]; $omax = $oindex + 1 - $maxlen; $nmax = $nindex + 1 - $maxlen; } } } if($maxlen == 0) return array(array('d'=>$old, 'i'=>$new)); return array_merge( diff(array_slice($old, 0, $omax), array_slice($new, 0, $nmax)), array_slice($new, $nmax, $maxlen), diff(array_slice($old, $omax + $maxlen), array_slice($new, $nmax + $maxlen))); } function print_array($array_to_display) { echo '
'; print_r($array_to_display); echo ''; } /*===================*/ /*Variables*/ /*===================*/ require("config.php"); #$content = ""; $old_files_list = "db_old_files"; //list of files in ./photos $new_files_list = "new_files_list"; $db_feed_source = "db_feed_source"; $Folder = 'photos'; $content = ListFiles($gallery_link, $content, $Folder, $SkipExts, $SkipObjects); $to_store = ""; // Init files if (!file_exists($old_files_list)) file_put_contents($old_files_list, ""); if (!file_exists($db_feed_source)) file_put_contents($db_feed_source, ""); /*===================*/ /*Computing*/ /*===================*/ #Todo : ajouter une condition : dois-je regénérer le flux ou utiliser les anciens fichiers ? // Load the list from files. $old_files_list_content = explode("\n", file_get_contents($old_files_list)); $new_files_list_content = explode("\n", $content); #debug // Generate and stock new elements $differences = diff($old_files_list_content, $new_files_list_content); for ($i=0; $i < count($differences); $i++) { if (is_array($differences[$i])){ for ($j=0; $j < count($differences[$i]["i"]); $j++) { if (strlen($differences[$i]["i"][$j]) > 2) $to_store .= $differences[$i]["i"][$j] . "\n"; } } } //Add new elements at the top of the feed's source $temp = file_get_contents($db_feed_source); $temp = $to_store . $temp; file_put_contents($db_feed_source, $temp); // Store the current file list for the next generation file_put_contents($old_files_list, $content); /*===================*/ /*XML Gen*/ /*===================*/ $temp = explode("\n", $temp); $pieceOfTitle; $titleLenght; echo "