- array_column: documentation ( source)
- preg_match_all: documentation ( source)
- var_export: documentation ( source)
<?php
$string = 'text^name1^PETER~text^secondname1^SMITH~text^phone1^023482348~text^adres1^STREETAVENUE 1B~text^postcode1^91201CA~text^woonplaats1^LIVINGPLACE~email^email1^peter@example.com';
preg_match_all('/(?:text|email)\^([^^]+)\^([^^~]*)/', $string, $matches, PREG_SET_ORDER);
var_export(
array_column($matches, 2, 1)
);