TGViewer
PHP Backend | YeaHub PHP Backend | YeaHub @yeahub_php_backend · 376 subscribers
Post #462 161
Функция array_column может доставать не только колонки массива, как казалось бы, но и свойства объектов:


enum Status: string {
case Active = 'active';
case Inactive = 'inactive';
case Pending = 'pending';
}

// What does self::cases() return?
var_dump(Status::cases());
// array(3) {
// [0]=> enum(Status::Active) // <- These are OBJECTS
// [1]=> enum(Status::Inactive) // <- Not arrays
// [2]=> enum(Status::Pending)
// }

// Each case object has public readonly properties:
$case = Status::Active;
echo $case->value; // "active" (string - the backing value)

// array_column can extract these properties!
$values = array_column(Status::cases(), 'value');
var_dump($values);
// array(3) {
// [0]=> string(6) "active"
// [1]=> string(8) "inactive"
// [2]=> string(7) "pending"
// }


А вы знали про такое?

🚀 Пост Guru PHP: @msavin_dev
www.php.net PHP: array_column - Manual Return the values from a single column in the input array
  • 👍 2
More from @yeahub_php_backend
  1. Oct 9, 2026#channel #плейлисты 📚 Просто о сложном. CutCode Этот канал — маст-хэв для любого PHP-разр…
  2. Oct 8, 2026#Собес #memory_layout #data_structures #cache_locality 🤔 Как отличие в расположении элеме…
  3. Oct 7, 2026#Собес #collector #garbage #promotion 🤔 Middle PHP Backend-разработчик в Альфа Страховани…
  4. Oct 5, 2026#Собес #profiling #performance 🤔 Если выяснили, что тормозит бэкенд — как бы вы отлаживал…
  5. Oct 2, 2026#trainer #практика 📚 Coddy Платформа-задачник по популярным языкам. Все по классике: реда…
  6. Oct 1, 2026#Собес #rollback #migration #deployment 🤔 Если после отката миграции всё заработало, а фи…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →