Reputation: 1732
I have an array jobs with fields '['patient']['name']', '['User']['name']', and below is result of array..
Job: Array
(
[0] => Array
(
[Patient] => Array
(
[name] => Patient1 User
)
[User] => Array
(
[name] => Alex Lopes
)
)
[1] => Array
(
[Patient] => Array
(
[name] => Patient1 Patient
)
[User] => Array
(
[name] => Mashal Othman
)
)
and so on
how can i retrieve value form specific index i can't use jobs[0] because i want dynamic value....if any one understand my problem please help me
Upvotes: 0
Views: 202
Reputation: 323
Alternatively, you could use array_shift
to grab the first element of the array. Throw that into a loop where you check if the array still contains elements and you should be able to get your data
ex:
$arrayCount = count($jobs);
while ($arrayCount > 0) {
$job = array_shift($jobs);
// Do your processing here
$arrayCount = count($jobs);
}
Upvotes: 1
Reputation: 532
Did you try Set::extract
? More here http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::extract
Upvotes: 1