Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Profile_fields to Object
  • Hi, I am trying to use my profile_fields on the view I couldn't find a solution in fuel doc of how to convert it to an object so i can echo data as string:
    my code so far: $profile_fields = \Format::forge(unserialize($users->profile_fields));

    The \Format::forge() does return a Fuel\Core\Format Object but I couldn't for example echo out this value: $profile_fields->about->social->facebook;

    my returned object:
    protected '_data' =>
    array (size=3)
    'about' =>
    array (size=4)
    'summary' =>'blabla'
    'emails' =>
    array (size=2)
    'phone' =>'+212649576598'
    'social' =>
    array (size=2)
    'experiences' =>
    array (size=2)
    0 =>'exp1'
    1 =>'exp2'
    'profile' =>
    array (size=2)
    0 =>'field1'
    1 =>'field2'
    protected 'ignore_namespaces' => true
  • philipptempelphilipptempel
    Accepted Answer
    From the dump you have provided it looks like the value of the 'about' property is an array thus it should be accessed like so

    This is most likely because the data you stored inside the profile_fields was originally an array before serializing thus it is an array after deserialization, too. What you should do is convert it recursively to an object and then store it as the value of the profile_fields (let it me serialized and unserialized automatically by the object through the "Observer_Typing" observer.
  • thanks lot :D I have come up with another solution, didn't drop by here since I asked, thanks again

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion