About pluck() method return

I need to convert structure field data to array with easy way.
But pluck() method return as Field type and i cant use in_array() or another array methods.

$attributes = $product->attributes()->toStructure()->pluck("attId");

array(5) {
  [0]=>
  object(Kirby\Cms\Field)#1035 (1) {
    ["attid"]=>
    string(2) "97"
  }
  [1]=>
  object(Kirby\Cms\Field)#1037 (1) {
    ["attid"]=>
    string(2) "98"
  }
  [2]=>
  object(Kirby\Cms\Field)#1039 (1) {
    ["attid"]=>
    string(2) "99"
  }
  [3]=>
  object(Kirby\Cms\Field)#1041 (1) {
    ["attid"]=>
    string(2) "96"
  }
  [4]=>
  object(Kirby\Cms\Field)#1043 (1) {
    ["attid"]=>
    string(3) "100"
  }
}

I dont want to use mapping array again.
Is there any method that return as standart array for any collection field in Kirby.

Expected output:

array(5) {
  [0]=>
  string(2) "97"
  [1]=>
  string(2) "98"
  [2]=>
  string(2) "99"
  [3]=>
  string(2) "96"
  [4]=>
  string(3) "100"
}

Two options:

$attributes = $page->social()->toStructure()->pluck("platform", ',');
$attributes = A::pluck($page->social()->yaml(), 'platform');
1 Like

More useful for me, thanks :+1:

1 Like