php array undefined index:,Laravel未定义索引显示数组值错误 (Laravel Undefined index Error in array values displa...

2015-06-13 10:17:52

0

I am using Laravel 4.2. I have two mysql tables OwnTable, OtherTable. I am getting values successfully from these tables through php.

My further PHP code look like below to display values in blade php,

if (!empty ($OwnTable)){

foreach($OwnTable as $owntbl){

$Finalvalue['OwnValue']['Name'] = $owntbl->Name;

}

}

if (!empty ($OtherTable)){

foreach($OtherTable as $othertbl){

$Finalvalue['OtherValue']['Name'] = $othertbl->Name;

}

}

$myData = array('Finalvalue' => $Finalvalue);

if(.....) {

return View::make('display')->with('myData', $myData);

}

And the code in display.blade look like below,

@foreach($myData['Finalvalue'] as $res)

{{{$res['OwnValue']['Name']}}}{{{$res['OtherValue']['Name']}}}

@endforeach

When I try to run the code, it gives an error 'Undefined index: OwnValue'.

I am sure I am doing some mistakes in array Handling. I am not so much talent in array handling. Highly appreciate if anyone suggest me in this. Thanks :-)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值