Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Połączenie wartości w tablicy
winiar789
post
Post #1





Grupa: Zarejestrowani
Postów: 130
Pomógł: 0
Dołączył: 15.11.2011

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


Mam coś takiego :

Array
(
[0] => Array
(
[data-position] => 1
[data-shopurl] =>nazwaa
[data-offer-price] =>
)

[1] => Array
(
[data-position] =>
[data-shopurl] =>
[data-offer-price] => 458.00
)

[2] => Array
(
[data-position] => 2
[data-shopurl] => nazwaa
[data-offer-price] =>
)

[3] => Array
(
[data-position] =>
[data-shopurl] =>
[data-offer-price] => 469.27
)
)

a chciałbym uzyskać:


Array
(
[0] => Array
(
[data-position] => 1
[data-shopurl] =>nazwaa
[data-offer-price] => 458.00
)

[1] => Array
(
[data-position] => 2
[data-shopurl] => nazwaa
[data-offer-price] => 469.27
)
)

Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
viking
post
Post #2





Grupa: Zarejestrowani
Postów: 6 381
Pomógł: 1116
Dołączył: 30.08.2006

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


I zamiast
  1. for($i = 0; $i < count($tablica); $i++) {
daj
  1. for($i = 0, $c = count($tablica); $i < $c; $i++) {
Teraz liczysz ilość elementów przy każdym przebiegu pętli.
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: 3.10.2025 - 12:59