Answer the question
In order to leave comments, you need to log in
Output a specific part of an array?
there is an object that I get like this:
it outputs$model->getAttribute('help');
string '{
"user": {
"type": "class",
"methodTitle": "modelTitle",
"class": "\\gm\\models\\users\\tables\\Users",
"fields": {
"username" : "attribute",
"first_name": "attribute",
"last_name": "attribute",
"second_name": "attribute"
}
}
}'
Answer the question
In order to leave comments, you need to log in
Good morning.
I understand that you have a connection in the getFields() model.
To get data through a connection, write like this:
More details here (working with connected data)
And supplement your question with the content of getAttribute('help'), what's inside, how does it work?
Symfony has a PropertyAccess Component
use Symfony\Component\PropertyAccess\PropertyAccess;
$accessor = PropertyAccess::createPropertyAccessor();
echo $accessor->getValue(json_decode($model->getAttribute('help')), 'user.fields.username'));
composer require "symfony/property-access"
$str = $model->getAttribute('help');
$array = json_decode($str);
echo $array['user']['fields']['username'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question