Title: Problem with Array and Loop for custom fields
Last modified: August 19, 2016

---

# Problem with Array and Loop for custom fields

 *  [mauricenaef](https://wordpress.org/support/users/mauricenaef/)
 * (@mauricenaef)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/problem-with-array-and-loop-for-custom-fields/)
 * Hi There,
 * I’m having a hard time figuring this out, since I’m still a php newbe.
 * For a custom Calendar widget I’m working on I need the php calendar to pull in
   the Dates from a custom field i’ve set up. So the Calendar requires the Dates
   with some other values in following format (manual version):
 *     ```
       $days = array(
       			"2"=>array($link,'class',$title),
       			"13"=>array($link,'class',$title),
       			"5"=>array($link,'class',$title)
       		    );
       ```
   
 * So I would like to reproduce the same array string put together dynamically pulled
   in from the custom fields. I’ve come up with following solution inside a custom
   loop:
 * `$days = array( $day=>array($link,'class', $title));`
 * But I don’t get the same output if I print_r the array. Instead of receiving 
   one array with values, I receive an array for each date. I’m thinking its got
   to do with the loop, and should rather use foreach, but I’m a bit lost how.
 * Hope this rather difficult explanation is somewhat understandable. Looking forward
   to some input… regards
 * Marcel

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 4 months ago](https://wordpress.org/support/topic/problem-with-array-and-loop-for-custom-fields/#post-1357615)
 * Please note I deleted your ‘duplicate’ topic.

Viewing 1 replies (of 1 total)

The topic ‘Problem with Array and Loop for custom fields’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [custom field](https://wordpress.org/support/topic-tag/custom-field/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)

 * In: [Everything else WordPress](https://wordpress.org/support/forum/miscellaneous/)
 * 1 reply
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 4 months ago](https://wordpress.org/support/topic/problem-with-array-and-loop-for-custom-fields/#post-1357615)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
