Skip to main content

Overview

By default, Instructor deserializes extracted data into PHP objects. Sometimes you may want to work with raw associative arrays instead - for example, when storing data in a database, passing to a JSON API, or when you don’t need the overhead of object instantiation. The intoArray() method allows you to use a PHP class to define the schema (structure and validation sent to the LLM) while receiving the result as a plain associative array.

Example

Expected Output