items_to_object

Modified on Thu, 9 Jul at 10:49 AM

items_to_object

TABLE OF CONTENTS

Convert a two-dimensional array to an object

Definition

object items_to_object(array[array] $input)

Returns an object consisting of key-value pairs from a two-dimensional array.

Parameters

array[array] $input

A two-dimensional array.

Returns

object

The object representing $input as key-value pairs.

Examples

Transformation
{
  object: items_to_object([['a','b'],['c','d']]),
  empty: items_to_object([])
}
Result
{
  "object": {
    "a": "b",
    "c": "d"
  },
  "b": null
}

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article