Witam,
Nie moge się połapać dlaczego nie działa na serwerze (cpanel) odwrocenie tablicy asocjacyjnej przez funkcje array_reverse, nie ma natomiast problemu na lokalu (serwer - Krasnal 2.7) (IMG:
http://forum.php.pl/style_emoticons/default/questionmark.gif)
kod wygląda następująco :
<?php
function tep_generate_category_pathDESC($id, $from = 'category', $categories_array = '', $index = 0) {
if ($from == 'product') {
$categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$id . "'");
while ($categories = tep_db_fetch_array($categories_query)) {
if ($categories['categories_id'] == '0') {
$categories_array[$index][] = array('id' => '0', 'text' => TEXT_TOP
); } else {
$category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$categories['categories_id'] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
$category = tep_db_fetch_array($category_query);
$categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']);
if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
// $categories_array[$index] = array_reverse($categories_array[$index]);
}
$index++;
}
} elseif ($from == 'category') {
$category_query = tep_db_query("select cd.categories_name, c.parent_id from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.categories_id = '" . (int)$id . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
$category = tep_db_fetch_array($category_query);
$categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']); if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_pathDESC($category['parent_id'], 'category', $categories_array, $index);
}
//$iii=0;
//for ($iii=10; $iii>0; $iii--)
// {
// array_push($categories_array[$index],$iii);
// }
$categories_array[$index] = array_reverse($categories_array[$index]); // $categories_array[$index] = rsort($categories_array[$index]);
return $categories_array;
}
?>
Ktoś ma moze na to jakies logiczne wytłumaczenie ?
a może jakiś inny sposób ?
z góry dzięki, pozdrawiam