I'm going crazy with this. So, let's say I got this array:
Array
(
[0] => Array
(
[variation_name] => variation_1
[license_type] => Array
(
[slug] => license_x
[price] => price_x
[dimensions] => dimensions_x
)
)
[1] => Array
(
[variation_name] => variation_2
[license_type] => Array
(
[slug] => license_y
[price] => price_y
[dimensions] => dimensions_y
)
)
[2] => Array
(
[variation_name] => variation_3
[license_type] => Array
(
[slug] => license_solid_z
[price] => price_z
[dimensions] => dimensions_z
)
)
)
and I want to echo the array values beginning with "license_solid" and the value of the array that contains it. To have the "license_solid" entries I run the following:
$attribute_pa_licenses = array_column($array, 'license_type');
$attribute_pa_license_slug = array_column($attribute_pa_licenses, 'slug');
foreach ($attribute_pa_license_slug as $value) {
if (0 === strpos($value, 'license_solid')) {
echo $value;
}
}
and it DO works, but I'm not understanding how to echo also the array "containing" $value in this example it should give variation_3
slugvalue and check if its value starts withlicense_solidand if yes you got the subArray you want.