Title: Fields() function returns an object instead of an array
Last modified: August 17, 2023

---

# Fields() function returns an object instead of an array

 *  Resolved [xerviami](https://wordpress.org/support/users/xerviami/)
 * (@xerviami)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/fields-function-returns-an-object-instead-of-an-array/)
 * Dear,
 * First of all, thank you very much for this wonderfull plugin !
 * I would like to use standard array functions (array_keys(), …) over PODS fields.
 * Therefore I use the field() function, which says it returns an array:
 * [https://docs.pods.io/code/pods/fields/](https://docs.pods.io/code/pods/fields/)
 * Unfortunatly, it returns an array of field objects.
 * Here is the output of a var_dump for the first field object:
 *     ```wp-block-code
       object(Pods\Whatsit\Field)#11326 (1) {
         ["args"]=>
         array(29) {
           ["object_type"]=>
           string(5) "field"
       ...
       ```
   
 * Therefore I can’t use php functions like array_keys() on this object.
 * I tried to convert it to an array by applying the array() function on it… but
   it only wraps the field object into an array of one element. The object remains
   an object and can not be passed to PHP array functions:
 *     ```wp-block-code
       array(1) {
         [0]=>
         object(Pods\Whatsit\Field)#11326 (1) {
           ["args"]=>
           array(29) {
             ["object_type"]=>
             string(5) "field"
       ...
       ```
   
 * I can ask the first element of this array and it gives me back the object, returning
   me to the previous step… 🙁
 * Is there any way to convert this object into an array and be able to use PHP 
   standard array function on it ?
 * Thank you very much
 * Kind regards
 * Xerviami

Viewing 1 replies (of 1 total)

 *  Plugin Author [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * (@sc0ttkclark)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/fields-function-returns-an-object-instead-of-an-array/#post-16980016)
 * Depending on what you want out of it, you could use `$field->get_args()` to get
   the array representation.

Viewing 1 replies (of 1 total)

The topic ‘Fields() function returns an object instead of an array’ is closed to
new replies.

 * ![](https://ps.w.org/pods/assets/icon.svg?rev=3286397)
 * [Pods - Custom Content Types and Fields](https://wordpress.org/plugins/pods/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/pods/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/pods/)
 * [Active Topics](https://wordpress.org/support/plugin/pods/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/pods/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/pods/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Scott Kingsley Clark](https://wordpress.org/support/users/sc0ttkclark/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/fields-function-returns-an-object-instead-of-an-array/#post-16980016)
 * Status: resolved