Hejka rebiata,
Napotkałem problem z którym ni jak nie wiem jak sobie poradzić (IMG:
style_emoticons/default/wink.gif)
Właściwie to wiem ale coś mi nie idzie.
Otóż jako wynik wybierania danych z bazy otrzymuję coś takiego:
array(1
) { [0
]=> array(13) { ["sku"]=> string
(9) "bsr4739cl" ["entity_id"]=> string
(4) "7391" ["name"]=> string
(35) "ABC Design Takeoff Stroller - Coral" ["manufacturer_id"]=> string
(4) "1662" ["manufacturer_name"]=> string
(10) "ABC Design" ["price"]=> string
(8) "249.9900" ["special_price"]=> string
(8) "200.0000" ["final_price"]=> string
(8) "200.0000" ["image"]=> string
(20) "/5/1/51076-501_1.jpg" ["url_path"]=> string
(38) "abc-design-takeoff-stroller-coral.html" ["percent_approved"]=> NULL ["vote_count"]=> NULL ["rating"]=> string
(6) "310.00" } } array(1
) { [0
]=> array(13) { ["sku"]=> string
(9) "bsr4739cr" ["entity_id"]=> string
(4) "7392" ["name"]=> string
(39) "ABC Design Takeoff Stroller - Cranberry" ["manufacturer_id"]=> string
(4) "1662" ["manufacturer_name"]=> string
(10) "ABC Design" ["price"]=> string
(8) "249.9900" ["special_price"]=> string
(8) "200.0000" ["final_price"]=> string
(8) "200.0000" ["image"]=> string
(20) "/5/1/51076-502_1.jpg" ["url_path"]=> string
(42) "abc-design-takeoff-stroller-cranberry.html" ["percent_approved"]=> NULL ["vote_count"]=> NULL ["rating"]=> string
(4) "3.00" } } array(1
) { [0
]=> array(13) { ["sku"]=> string
(9) "bsr4743cr" ["entity_id"]=> string
(4) "7396" ["name"]=> string
(38) "ABC Design Avito Pushchair - Cranberry" ["manufacturer_id"]=> string
(4) "1662" ["manufacturer_name"]=> string
(10) "ABC Design" ["price"]=> string
(8) "249.9900" ["special_price"]=> string
(8) "200.0000" ["final_price"]=> string
(8) "200.0000" ["image"]=> string
(22) "/5/1/51075-502_1_1.jpg" ["url_path"]=> string
(41) "abc-design-avito-pushchair-cranberry.html" ["percent_approved"]=> NULL ["vote_count"]=> NULL ["rating"]=> string
(6) "372.00" } } array(1
) { [0
]=> array(13) { ["sku"]=> string
(9) "bsr4743lm" ["entity_id"]=> string
(4) "7397" ["name"]=> string
(33) "ABC Design Avito Pushchair - Lime" ["manufacturer_id"]=> string
(4) "1662" ["manufacturer_name"]=> string
(10) "ABC Design" ["price"]=> string
(8) "249.9900" ["special_price"]=> string
(8) "200.0000" ["final_price"]=> string
(8) "200.0000" ["image"]=> string
(20) "/5/1/51075-503_1.jpg" ["url_path"]=> string
(36) "abc-design-avito-pushchair-lime.html" ["percent_approved"]=> NULL ["vote_count"]=> NULL ["rating"]=> string
(7) "-385.00" } } array(1
) { [0
]=> array(13) { ["sku"]=> string
(10) "bsr4758bcr" ["entity_id"]=> string
(4) "7403" ["name"]=> string
(51) "ABC Design Cobra 2 in 1 Pushchair - Black/Cranberry" ["manufacturer_id"]=> string
(4) "1662" ["manufacturer_name"]=> string
(10) "ABC Design" ["price"]=> string
(8) "459.9900" ["special_price"]=> string
(8) "420.0000" ["final_price"]=> string
(8) "420.0000" ["image"]=> string
(23) "/3/1/31171-530502_1.jpg" ["url_path"]=> string
(54) "abc-design-cobra-2-in-1-pushchair-black-cranberry.html" ["percent_approved"]=> NULL ["vote_count"]=> NULL ["rating"]=> string
(6) "166.00" } }
Co to jest ?
Otóż jest to tablica a w niej kolejnych 5 tablic. Mając taki miszmasz do dyspozycji chciałbym bez o ile to mozliwe specjalnych kombinacji wyciągać dane w kolejności:
index1 - ["sku"] ..... kolejno ze wszystkich tablic,
index2 - ["entity_id"] ..... kolejno ze wszystkich tablic,
itd ... itd ...
nie wiem jednak jak to zrobić.
Próbowałem tak:
Pewnie zwróciliście uwagę na to, że wszystkie tablice to array(1), no własnie, w tej chwili wpadło mi to w oko. Chyba muszę dodać jakiś ekstra licznik bo jak miałbym rozróżnić która ma być czytana ?
Dobrze kombinuję ?
A może poprostu sam proces ich generowania powinienem wziąć pod lupę ?
<?php
$output =
array(1
) {[0
]=> array(13) ( ["sku"]=> string
(9) "bsr4739cl" ["entity_id"]=> string
(4) "7391" ["name"]=> string
(35) "ABC Design Takeoff Stroller - Coral" ["manufacturer_id"]=> string
(4) "1662" ["manufacturer_name"]=> string
(10) "ABC Design" ["price"]=> string
(8) "249.9900" ["special_price"]=> string
(8) "200.0000" ["final_price"]=> string
(8) "200.0000" ["image"]=> string
(20) "/5/1/51076-501_1.jpg" ["url_path"]=> string
(38) "abc-design-takeoff-stroller-coral.html" ["percent_approved"]=> NULL ["vote_count"]=> NULL ["rating"]=> string
(6) "310.00" } }
array(1
) {[0
]=> array(13) { ["sku"]=> string
(9) "bsr4739cr" ["entity_id"]=> string
(4) "7392" ["name"]=> string
(39) "ABC Design Takeoff Stroller - Cranberry" ["manufacturer_id"]=> string
(4) "1662" ["manufacturer_name"]=> string
(10) "ABC Design" ["price"]=> string
(8) "249.9900" ["special_price"]=> string
(8) "200.0000" ["final_price"]=> string
(8) "200.0000" ["image"]=> string
(20) "/5/1/51076-502_1.jpg" ["url_path"]=> string
(42) "abc-design-takeoff-stroller-cranberry.html" ["percent_approved"]=> NULL ["vote_count"]=> NULL ["rating"]=> string
(4) "3.00" } }
array(1
) { [0
]=> array(13) { ["sku"]=> string
(9) "bsr4739lm" ["entity_id"]=> string
(4) "7393" ["name"]=> string
(34) "ABC Design Takeoff Stroller - Lime" ["manufacturer_id"]=> string
(4) "1662" ["manufacturer_name"]=> string
(10) "ABC Design" ["price"]=> string
(8) "249.9900" ["special_price"]=> string
(8) "200.0000" ["final_price"]=> string
(8) "200.0000" ["image"]=> string
(20) "/5/1/51076-503_1.jpg" ["url_path"]=> string
(37) "abc-design-takeoff-stroller-lime.html" ["percent_approved"]=> NULL ["vote_count"]=> NULL ["rating"]=> string
(6) "596.00" } }
array(1
) {[0
]=> array(13) { ["sku"]=> string
(9) "bsr4743cl" ["entity_id"]=> string
(4) "7395" ["name"]=> string
(34) "ABC Design Avito Pushchair - Coral" ["manufacturer_id"]=> string
(4) "1662" ["manufacturer_name"]=> string
(10) "ABC Design" ["price"]=> string
(8) "249.9900" ["special_price"]=> string
(8) "200.0000" ["final_price"]=> string
(8) "200.0000" ["image"]=> string
(20) "/5/1/51075-501_1.jpg" ["url_path"]=> string
(37) "abc-design-avito-pushchair-coral.html" ["percent_approved"]=> NULL ["vote_count"]=> NULL ["rating"]=> string
(6) "236.00" } }
array(1
) { [0
]=> array(13) { ["sku"]=> string
(9) "bsr4743cr" ["entity_id"]=> string
(4) "7396" ["name"]=> string
(38) "ABC Design Avito Pushchair - Cranberry" ["manufacturer_id"]=> string
(4) "1662" ["manufacturer_name"]=> string
(10) "ABC Design" ["price"]=> string
(8) "249.9900" ["special_price"]=> string
(8) "200.0000" ["final_price"]=> string
(8) "200.0000" ["image"]=> string
(22) "/5/1/51075-502_1_1.jpg" ["url_path"]=> string
(41) "abc-design-avito-pushchair-cranberry.html" ["percent_approved"]=> NULL ["vote_count"]=> NULL ["rating"]=> string
(6) "372.00" } };
$c=1;
?>
<table border="1">
<tr>
<th></th>
<?php
foreach ($output as $key => $html)
{
echo "<th>SKU ".$key."</th>"; }
?>
</tr>
<tr>
<td>SKU</td>
<?php
foreach ($output as $key => $html)
{
echo "<td>".$html['sku']."</td>"; }
?>
</tr>
</table>
Podpowiedzcie ..... proszę (IMG:
style_emoticons/default/wink.gif)
Ten post edytował PHPRexio 11.07.2016, 09:23:17