Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [funkcja] array_combine, Jak ktoś ma php <5
Spirit86
post
Post #1





Grupa: Zarejestrowani
Postów: 607
Pomógł: 23
Dołączył: 8.09.2004
Skąd: Wrocław

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


Napisałem funckje, może się komuś przyda. Odsyłam do manuala array_combine" title="Zobacz w manualu php" target="_manual
  1. <?php
  2. if(!function_exists('array_combine'))
  3. {
  4.  
  5.  function array_combine($FirstArray, $SecondArray)
  6.  {
  7.     
  8.     $FirstArray = merage_array($FirstArray);
  9.     $SecondArray = merage_array($SecondArray);
  10.     
  11.     if(is_array($FirstArray) AND is_array($SecondArray))
  12.     {
  13.     
  14.         $ReturnArray = array();
  15.         for($i=0;$i<count($FirstArray);$i++)
  16.         {
  17.              $ReturnArray[$FirstArray[$i]] = $SecondArray[$i]; 
  18.         }
  19.  
  20.         return $ReturnArray;       
  21.     }
  22.     else
  23.     {
  24.       return false;
  25.     }
  26.  } 
  27. function merage_array($array, $Mode=1)
  28. {
  29.   //Modes: 1->Return Values; 2->Return Keys
  30.   $RetArray = array();
  31.   foreach($array AS $key =>$value)
  32.   {
  33.      $RetArray[] = ($Mode==1) ? $value : $key; 
  34. }
  35. return $RetArray;
  36. }
  37. ?>

Pozdrawiam

Ten post edytował Spirit86 20.03.2006, 18:05:12


--------------------
Audio: Metallica, Soil, RHCP, OffSpring, Green Day, "Retro", Gorillaz, Disturbed, Coma
DB: MySQL 4.1 | php: 4.4.3 Pomogłem Ci? Wciśnij przycisk POMÓGŁ.
Go to the top of the page
+Quote Post

Posty w temacie


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 - 14:56