1

I am using following array

 Array
 (
    [0] => Array
     (
        [id] => 6
        [key] => SITE_NAME
        [value] => Webg Smarty CMS Small
        [name] => general
        [title] => website name
        [type] => text
)

[1] => Array
    (
        [id] => 32
        [key] => PHONE_NUMBER
        [value] => 713-332-4675 
        [name] => general
        [title] => Phone Number
        [type] => text
    )

)

I want to show [0][value], [1][value]

I am using foreach but i am unable to print values

how to show it?

2 Answers 2

1
<?php
//$arr = your nested array aboe 
foreach($arr as $v){
  echo $v['value']; //this will print 'Webg Smarty CMS Small' first in your example followed by '713-332-4675'
}

$arr[0]['value'] will give you 'Webg Smarty CMS Small'
$arr[1]['value'] will give you '713-332-4675'
Sign up to request clarification or add additional context in comments.

Comments

0

Try this

foreach($yourArr as $key => $value)
{
  echo $value['value'];
}

OR

echo $yourArr[0]['value'];  //print value of first element
echo $yourArr[0]['key'];    //print key of first element

6 Comments

I tried this but it is printing all values i want to show only single value like [0][value], [1][key]
It can't print all values. It print only value
yes but i want to echo each value with differnt style like <div class="phone">[1][value]</div>, <div class="title">[0][value]</div>
how to echo $yourArr[0]['value']; ??
how to display it in smarty template??
|

Your Answer

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