Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] How to get specific item from array?
#1

[eluser]solid9[/eluser]
hi guys

I have an array called 'swap'
Now it has values below,
[swapid] => 14
[date_posted] => 2012-03-10
[offering] => eight
[seeking] => 8

I'm going to use the values in 'view'
But I want to get only the 'offering' value.
How to do fetch that value?

Can you show me the right codes please.

Thanks in advanced.
#2

[eluser]solid9[/eluser]
I tried foreach but it show some error,

here is the codes I used.
Code:
foreach ($swap as $item):
echo $item->offering;  
endforeach;

#3

[eluser]plain jane[/eluser]
Code:
$swap['offering'];
This might help
#4

[eluser]solid9[/eluser]
@Jane

I've tried your suggestion but sorry.
I've got error.

Code:
Offering
Fatal error: Cannot use object of type stdClass as array in /home/www/barterswapping.com/application/views/post_page.php on line 32

#5

[eluser]solid9[/eluser]
Okay guys and gals

I've solved my own problem.

I directly accessed it using this codes below and without using FOREACH.
Code:
$swap->offering;

Thanks to GOD alleluya... Smile

Problem SOLVED.




Theme © iAndrew 2016 - Forum software by © MyBB