Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [php] - Tablica array_reverse - dziala i nie dzial
pieto
post
Post #1





Grupa: Zarejestrowani
Postów: 227
Pomógł: 1
Dołączył: 12.05.2002
Skąd: gdańsk

Ostrzeżenie: (0%)
-----


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) questionmark.gif

kod wygląda następująco :
  1. <?php
  2.  
  3.  function tep_generate_category_pathDESC($id, $from = 'category', $categories_array = '', $index = 0) {
  4. global $languages_id;
  5.  
  6. if (!is_array($categories_array)) $categories_array = array();
  7.  
  8. if ($from == 'product') {
  9. $categories_query = tep_db_query("select categories_id from " . TABLE_PRODUCTS_TO_CATEGORIES . " where products_id = '" . (int)$id . "'");
  10. while ($categories = tep_db_fetch_array($categories_query)) {
  11. if ($categories['categories_id'] == '0') {
  12. $categories_array[$index][] = array('id' => '0', 'text' => TEXT_TOP);
  13. } else {
  14. $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 . "'");
  15. $category = tep_db_fetch_array($category_query);
  16.  
  17. $categories_array[$index][] = array('id' => $categories['categories_id'], 'text' => $category['categories_name']);
  18.  
  19. if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_path($category['parent_id'], 'category', $categories_array, $index);
  20.  
  21. // $categories_array[$index] = array_reverse($categories_array[$index]);
  22. }
  23. $index++;
  24. }
  25. } elseif ($from == 'category') {
  26. $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 . "'");
  27. $category = tep_db_fetch_array($category_query);
  28.  
  29. $categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']);
  30.  if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_pathDESC($category['parent_id'], 'category', $categories_array, $index);
  31. }
  32.  
  33. //$iii=0;
  34. //for ($iii=10; $iii>0; $iii--)
  35. // {
  36. // array_push($categories_array[$index],$iii); 
  37. // }
  38. $categories_array[$index] = array_reverse($categories_array[$index]);
  39. // $categories_array[$index] = rsort($categories_array[$index]);
  40.  
  41. return $categories_array;
  42. }
  43.  
  44. ?>


Ktoś ma moze na to jakies logiczne wytłumaczenie ?
a może jakiś inny sposób ?

z góry dzięki, pozdrawiam


--------------------
Materiały i Wypracowania znajdziesz na zgapa.pl i
Encyklopedii Zgapedia
Jedyny przedawkowany portal motoryzacyjny to autoholik.pl
Go to the top of the page
+Quote Post
NuLL
post
Post #2





Grupa: Zarejestrowani
Postów: 2 262
Pomógł: 21
Dołączył: 3.05.2004
Skąd: Sopot, Krakow, W-wa

Ostrzeżenie: (0%)
-----


Moze wkleisz cos krotszego ktore nie jest smietnikiem bo trudno sie w tym polapac questionmark.gif


--------------------
Javascript, Coffeescript, Node.js, Mongo, CouchDb, chmury, workery & inne bajery - zycie jest zbyt krotkie aby miec nudna prace :)
Go to the top of the page
+Quote Post
pieto
post
Post #3





Grupa: Zarejestrowani
Postów: 227
Pomógł: 1
Dołączył: 12.05.2002
Skąd: gdańsk

Ostrzeżenie: (0%)
-----


głównie chodzi o ten fragment
  1. <?php
  2.  
  3.  elseif ($from == 'category') {
  4. $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 . "'");
  5. $category = tep_db_fetch_array($category_query);
  6.  
  7. $categories_array[$index][] = array('id' => $id, 'text' => $category['categories_name']);
  8.  if ( (tep_not_null($category['parent_id'])) && ($category['parent_id'] != '0') ) $categories_array = tep_generate_category_pathDESC($category['parent_id'], 'category', $categories_array, $index);
  9. }
  10.  
  11.  
  12.  $categories_array[$index] = array_reverse($categories_array[$index]);
  13.  
  14. ?>


--------------------
Materiały i Wypracowania znajdziesz na zgapa.pl i
Encyklopedii Zgapedia
Jedyny przedawkowany portal motoryzacyjny to autoholik.pl
Go to the top of the page
+Quote Post
mariuszn3
post
Post #4





Grupa: Zarejestrowani
Postów: 352
Pomógł: 0
Dołączył: 22.01.2006

Ostrzeżenie: (0%)
-----


Upewnij się, że na pewno chodzi o array_reverse()
Przetestuj na najprostszym możliwym odosobnionym przykładzie, bo tu może tysiąc innych rzeczy szwnankować
Go to the top of the page
+Quote Post
g00fy
post
Post #5





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 23.11.2004

Ostrzeżenie: (0%)
-----


a zrób reset , array_reverse i print_r przed i po
spróbój jeszcze jakby co zrobić

$array2= array_reverse(&$array);
$array&=$array2;
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 06:25