Sven Rautenberg: wie sortiere ich $_FILES Array um ?

Beitrag lesen

Moin!

ich habe ein kleines Syntax bzw. Denkproblem. Ich habe folgende arrays :

print_r($_POST['id']);
Array ( [312] => 4633 [313] => 4632 )

print_r($_POST['ta']);
Array ( [312] => adwdasdasdas [313] => dassdaadsasd )

und die sortiere ich via PHP wie folgt um

Da sortierst du nichts um, du entfernst die Indexwerte.

Etwas, was die Funktion array_values() auch tut.

$fea = array_values($_POST['id']);
$fec = array_values($_POST['ta']);

Viel simpler sogar. :)

$cx = 0; $cz = 0;
  # Array in Array raussortieren
foreach ($_POST['id'] as $fea) {$id[$cx] = $fea; $cx++;}
foreach ($_POST['ta'] as $fec) {$ta[$cz] = $fec; $cz++;}

nun möchte ich auch gerne das FILES Array umsortieren wie oben ... nur wie mache ich das ?

Genau so.

$whatever = array_values($_FILES['anhang']['name']);

print_r($_FILES);
Array ( [anhang] => Array ( [name] => Array ( [312] => xyz.txt [313] => abc.txt ) [type] => Array ( [312] => text/plain [313] => text/plain ) [tmp_name] => Array ( [312] => /tmp/php8FGWRU [313] => /tmp/php2dROAF ) [error] => Array ( [312] => 0 [313] => 0 ) [size] => Array ( [312] => 1671 [313] => 677 ) ) )

- Sven Rautenberg

--
"Love your nation - respect the others."