PHP convert array to resource
arrays, object, php, resources
Solution
What I'm looking for, would probably something like this:
$resource_var = (resource) $array(var)
You will never find that. A resource is an internal data-type in PHP. If (and only if) you write yourself a PHP extension and load it, you could do the following:
$resource = array_resource_create($array);
Your PHP extension then would create that resource (as the `mysql` extension for example creates its specific resource type) within that `array_resource_create` function. However, it would be useless, because there is no other function so far that could deal with that resource.
Problem
For visual representation, for simplicity and of course to feed my curiosity, I'm wondering how to convert a PHP array into a valid PHP resource. See the below example: (example image created with dBug component available at http://dbug.ospinto.com/) I've made 3 examples: - resource: this is the typical representation of a MySQL resource, visualized as a grid - object: a handmade create object from an array - array: a handmade multidimensional array As you can see, the resource is a visual beauty, while the object and array are constructed by using multidimensional arrays, using poor numeric array indexes to bind them together :( What I'm looking for, would probably be something like this: ``` $resource_var = (resource) $array_var; ```