use yii\helpers\Html; $htmlAttrs = ['class' => 'btn btn-primary', 'id' => 'button-1']; $id = Html::getAttributeName($htmlAttrs, 'id'); echo $id; // Output: button-1
use yii\helpers\Html; $htmlAttrs = ['class' => 'btn btn-primary', 'data-value' => '12345']; $dataValue = Html::getAttributeName($htmlAttrs, 'data-value'); echo $dataValue; // Output: 12345Package library: yii2\helpers\Html. In conclusion, the Html helper getAttributeName function is useful when you need to retrieve a specific attribute value from an HTML attributes array. It is part of the Yii2 framework Html helper library.