Welcome Guest, Not a member yet? Register   Sign In
Getting associative array value without foreach loop?
#1

[eluser]jsuissa[/eluser]
Hi,

So I'm able to get name/values with a foreach loop from $data['resume'] shown below.

However I can't figure out how to access a single value from this row_array provided I already know the name associated with the value (i.e. name: vanity_name value: ABC)

Is it possible to get this value without using a foreach loop?

Code:
$data['resume'] = $this->resume_model->get_resume_profile($id);

Thanks in advance for any help!

Justin
#2

[eluser]InsiteFX[/eluser]
Try
Code:
echo $data['resume']['vanity_name'];
#3

[eluser]Dhanapal MCA[/eluser]
Hi you can use this below code:

echo $data['resume']['vanity_name'];
#4

[eluser]Bhashkar Yadav[/eluser]
extract() function may help you. it imports variables into the local symbol table from an array.
#5

[eluser]jsuissa[/eluser]
Thanks so much, echo $data[‘resume’][‘vanity_name’]; worked perfectly.

I will also check out the extract function.

Best,

Justin
#6

[eluser]InsiteFX[/eluser]
You can also assign it to a new string variable.
Code:
$vanity = $data['resume']['vanity_name'];




Theme © iAndrew 2016 - Forum software by © MyBB