1

I have a multi value cck field.

I can read any single id with node->field_multip[0][id].

How do I read all ids? I tried a for loop with field_multip.length but the page never finishes loading. What's the right way of doing this?

field_multip
   [0] 
      [id]
      [sec]
   [1]
      [id]
      [sec]
   [2]
      [id]
      [sec]

2 Answers 2

2
foreach ($node->field_multip as $key => $value) {
    // code
}
Sign up to request clarification or add additional context in comments.

1 Comment

This did the job, but looks like I still need a way to get the length of the multi-value field for other reasons. I've started another question here if anyone can help with that specific question: http://stackoverflow.com/questions/3390947/finding-length-of-multi-value-field Looks like drupal may be different.
2

Try this:

$array = ...
foreach($array as $obj) {
   //do something with $obj->id...
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.