Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php] przekształcenie tablicy (spłaszczenie?)
mlawnik
post
Post #1





Grupa: Zarejestrowani
Postów: 455
Pomógł: 49
Dołączył: 12.04.2010

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


Witam,

Czy ktoś mógłby mnie nakierować w jaki sposób tablicę pobraną przez PDO::FETCH_ASSOC:

array
0 =>
array
'subjectId' => string '1' (length=1)
'subjectName' => string 'biologia' (length=8)
1 =>
array
'subjectId' => string '2' (length=1)
'subjectName' => string 'chemia' (length=6)
2 =>
array
'subjectId' => string '3' (length=1)
'subjectName' => string 'fizyka' (length=6)
3 =>
array
'subjectId' => string '4' (length=1)
'subjectName' => string 'geografia' (length=9)
4 =>
array
'subjectId' => string '5' (length=1)
'subjectName' => string 'historia' (length=8)
5 =>
array
'subjectId' => string '6' (length=1)
'subjectName' => string 'j. niemiecki' (length=12)
6 =>
array
'subjectId' => string '7' (length=1)
'subjectName' => string 'j. polski' (length=9)
7 =>
array
'subjectId' => string '8' (length=1)
'subjectName' => string 'matematyka' (length=10)
8 =>
array
'subjectId' => string '9' (length=1)
'subjectName' => string 'muzyka' (length=6)
9 =>
array
'subjectId' => string '10' (length=2)
'subjectName' => string 'plastyka' (length=8)
10 =>
array
'subjectId' => string '11' (length=2)
'subjectName' => string 'wi' (length=2)

Przekształcić do takiej postaci:

array
1 => string 'biologia' (length=8)
2 => string 'chemia' (length=6)
3 => string 'fizyka' (length=6)
4 => string 'geografia' (length=9)
5 => string 'historia' (length=8)
6 => string 'j. niemiecki' (length=12)
7 => string 'j. polski' (length=9)
8 => string 'matematyka' (length=10)
9 => string 'muzyka' (length=6)
10 => string 'plastyka' (length=8)


Pozdrawiam,
mlawnik
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Nie, w tym wypadku $key nie jest potrzebne
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 18.09.2025 - 15:58