Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Hilfe! Array durchlaufen - Werte zurückgeben

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German
View previous topic :: View next topic  
Author Message
nitroox88
Smarty n00b


Joined: 11 Jan 2021
Posts: 1

PostPosted: Tue Jan 12, 2021 7:09 am    Post subject: Hilfe! Array durchlaufen - Werte zurückgeben Reply with quote

Hallo zusammen,

danke, dass ich hier sein darf. Heute würde ich mich gerne gleich mit einem Problem an euch wenden. Ich habe ein Array welches ich durchlaufen will um an die einzelnen Werte zu gelangen, vielleicht kann hier jemand helfen?

Das Array :

Code:

Array (
[30] => Array (
[categories_id] => 30
[categories_status] => 1
[categories_image] => e.jpg
[external_id] =>
[language_code] => de
[categories_name] => Abdrucklöffel
[categories_heading_title] => Abdrucklöffel glatt + perforiert - Rim Lock und Ehricke
[categories_description] =>
  [products] => Array (
    [products_id] => 30706
    [products_quantity] => 10.00
    [products_model] => al553
    [nr] => 109
    [products_image] =>
    [products_price] => 389.83
    [products_model_cut] => al553
    [products_name] => 100 Abdrucklöffel 10er Sets Edelstahl - Rim-Lock perforiert XL-L-M-S-XS
    [products_description] => 
    )
)


Mein Versuch:

Code:
{foreach from=$categories.{$category.categories_id} item=v}
                     <li>{$categories.products.$v}</li>
                     {/foreach}
Back to top
View user's profile Send private message
Grizzly
Smarty Pro


Joined: 15 Apr 2011
Posts: 172
Location: Germany

PostPosted: Wed Jan 13, 2021 8:40 am    Post subject: Reply with quote

Hey,

kann es sein, dass du ein verschachteltest array hast?

Also so in der Art wie das hier:

Code:

$cat1 = array("categories_id" => 29,"categories_status" => 1... );
$cat1 = array("categories_id" => 30,"categories_status" => 1... );
$categories = array($cat1, $cat2);


Wenn ja, dann kannst du in deinem foreach nicht darüber gehen, denn du müsstest z. B. über $categories.0.categories_id gehen, wobei 0 dann der Index ist.

Außerdem gehst du im for each falsch an die Sache ran. Dein "aktuelles" item, welches den Variabelnamen "v" hat, ist das item welches deine Category darstellt. Also sprich, du müsstest so abfragen:



Code:
<li>{$v.products.0.products_id}</li>


Wobei auch hier wieder die 0 den Index darstellt.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: German All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP