0

Hi i need to convert array to object.

So i use :

$object = (object)$array;

But my problem is i have not the same object. In my current object i have :

class Proxies\__CG__\...#1142 (25) { my object...

And when i convert array to string i have :

class stdClass#1394 (1) {


public ${0} =>


class Proxies\__CG__\...#1142 (25) { my object...

How i can to delete the class std and public 0 ?

12
  • Why did you convert the object to an array in the first place? Commented Feb 7, 2017 at 10:18
  • What does the array look like? When you convert an array to an object, each index of the array becomes a property name in the object. It sounds like you really want to convert $array[0] to an object. Commented Feb 7, 2017 at 10:20
  • When you convert an array to an object, it always creates stdClass. How is it supposed to know that you want some other class? Commented Feb 7, 2017 at 10:21
  • To convert an array to a specific class, you need to write a function that does it. Commented Feb 7, 2017 at 10:22
  • Its in symfony, i need to set an object to my entity, and i set the before last parameters. So for get this before last parameter, i need to get an array of object, i use array_splice($array, -2, 1, true), then i convert this to object Commented Feb 7, 2017 at 10:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.