在PHP中从数组获取值时出现问题

iam using the Zend framework and assign the array from the controller to view. The array is coming from execution of stored procedure result

$results = callProcedure('testprocedure', $in)//$in is an array of input values 
$view->results =$results['record'];

In The $results['record'] array iam having two values such as 'NO' and 'name' and i want to assign this values also the view.However this values will be available in the $results['record']; array. But in the view i need have the values separately i dont repeat them in the loop . if i dont do for each iam not getting the values

How do i assign these values from the controller

$view->no=???
$view->NAME=???

How do i access $results['record'] array in the view

$this->results['NO']//  it is saying undefined index 'NO'
$this->results['NAME']// it is saying undefined index 'NAME'    

#0

To access the vies from the controller you must use $this->view->. Then from the view its $this-> because when in the view $this is the view object itself.

so try:

$results = callProcedure('testprocedure', $in)//$in is an array of input values 
$this->view->results = $results['record'];

From the controller it looks like this echoing them:

echo 'no: ' .$this->view->results['no']. '<BR />';
echo 'name: ' .$this->view->results['name'];

So do to it from the view just:

<?php
    echo 'no: ' . $this->results['no'] . '<BR />';
    echo 'name: ' . $this->results['name'];
?>

推荐文章

List集合

List集合

推荐文章

【人生】程序员装逼指南----速成篇 .

【人生】程序员装逼指南----速成篇 .

推荐文章

关于编写群发软件过程的几点想法

关于编写群发软件过程的几点想法

推荐文章

事件处理程序

事件处理程序

推荐文章

python 定位

python 定位

推荐文章

c/c++程序编译连接过程

c/c++程序编译连接过程

推荐文章

clearLog_New_v2.sh

clearLog_New_v2.sh

推荐文章

linux磁盘分区与系统目录介绍

linux磁盘分区与系统目录介绍

推荐文章

第二十四章 面向对象------属性

第二十四章 面向对象------属性

推荐文章

eclipse 配置spring IDE详解(配置好以后可以查看bean的依赖关系,很清晰。而且在xml中写bean的时候可以自动提示引用类路径等)

eclipse 配置spring IDE详解(配置好以后可以查看bean的依赖关系,很清晰。而且在xml中写bean的时候可以自动提示引用类路径等)

推荐文章

VM装redhat错误(设备未找到)

VM装redhat错误(设备未找到)

推荐文章

C/C++ IDE for linux

C/C++ IDE for linux

推荐文章

805. Split Array With Same Average

805. Split Array With Same Average

推荐文章

Delphi与C#的比较

Delphi与C#的比较

推荐文章

23集合框架

23集合框架

推荐文章

Visual Studio 2008 -- New Web Site

Visual Studio 2008 -- New Web Site