Remove part of string PHP

From a dataset I always get postcode in the return of this format

Countrycode-postcode Example if I echo $postcode it will return SV-0540

I want it to only return the number and not the “xx-”.

I used the search function and cant wrap my head around if I should (and how) trim the results or use preg_match to remove. Please advice

Can you change how it gets returned, before we step into how it can be handled downstream?

I fixed it by doing as foolow

$pattern = ‘/[A-Z]{2}-/’;
$replacement = ‘’;
‘Postcode’ => preg_replace($pattern, $replacement, $postcode),

Sponsor our Newsletter | Privacy Policy | Terms of Service