i have two arrays:
$a =array(
'standard' => (object) array( 'id' => 'standard', 'title' => 'AustPost Standard' ),
'registered' => (object) array( 'id' => 'registered', 'title' => 'AustPost Registered' ),
'insured' => (object) array( 'id' => 'insured', 'title' => 'AustPost Insured' ),
'express' => (object) array( 'id' => 'express', 'title' => 'AustPost Express' ),
'satchexp' => (object) array( 'id' => 'satchexp', 'title' => 'AustPost Satchel Express' ),
'satchreg' => (object) array( 'id' => 'satchreg', 'title' => 'AustPost Satchel Registered' ),
'satchpla' => (object) array( 'id' => 'satchpla', 'title' => 'AustPost Satchel Platnium' )
);
and
$b = array( 'standard', 'sea', 'air', 'satchexp', 'satchreg', 'satchpla' )
how can i create a new array $c that has only elements from array $a that appear in array $b?
It’s called array intersection
You can do it either by key or value.
In your case in $a you have (standard’, ‘sea’, ‘air’..) as keys, but in $b those words are actually values and the keys are (0, 1, 2…)
You can easilly flip the array $b to make the words array keys. Then you can intersect arrays by keys