Fields() function returns an object instead of an array

[ad_1]

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/

Unfortunatly, it returns an array of field objects.

Here is the output of a var_dump for the first field object:

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:

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

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer