0

How can i get each value from the below array in smarty? I have :

{$categ|var_dump} is

array(16) {
  [0]=>
  string(63) "
  string(6) "MEN
  string(29) "
  string(0) ""
  [4]=>
  string(6) "
  string(97) "
  string(23) "Incaltaminte barbati
  string(29) "
  string(0) ""
  [9]=>
  string(6) "
  string(72) "
  string(10) "Pantofi
  string(29) "
  string(0) ""
  [14]=>
  string(6) "
  string(5) "PRADA"
}

I have tried : {$categ[8]} ..{$categ[x]} but its not returning nothing.

Have any ideea ?

2 Answers 2

1

Have you tried doing a foreach loop in Smarty?

<ul>
{foreach from=$myArray item=foo}
    <li>{$foo}</li>
{/foreach}
</ul>
Sign up to request clarification or add additional context in comments.

Comments

0

You can use foreach to access element of array.You can use following example to learn that how to access array element.

$a = array(
    "one" => 1,
    "two" => 2,
    "three" => 3,
    "seventeen" => 17
);

foreach ($a as $k => $v) {
    echo "\$a[$k] => $v.\n";
}

Here $k - will indicate to key of the array. $v- will indicate to value of particular key.

To know more please refer following link- http://php.net/manual/en/control-structures.foreach.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.