M.Ahmed
M.Ahmed

Reputation: 67

How to call first array element in smarty

I have associative array:

 Array ( [7] => Array ( [media_id] => 7 ) Array ( [8] => Array ( [media_id] =>      8 ) Array ( [5] => Array ( [media_id] => 5 ) Array ( [18] => Array ( [media_id] => 18 ) 

I need to call only the first element with smarty template engine.

Upvotes: 0

Views: 2349

Answers (2)

asif
asif

Reputation: 11

You should reset the array once again.

$arrayNew=reset($arrayOld);
$value=$arrayNew[0];

value will return the first element.

Upvotes: 0

cn0047
cn0047

Reputation: 17091

Try this:

{$arrayVar|@array_shift}

Upvotes: 1

Related Questions