- print_r: documentation ( source)
- preg_match_all: documentation ( source)
<?php
$string = "This is my string but it also has %APP:name_of_the_app|ID:123123123% a bunch of other stuff in it";
$apps = array();
if (preg_match_all("/%APP:(.*?)\|ID:([0-9]+)%/", $string, $matches)) {
for ($i = 0; $i < count($matches[0]); $i++) {
$apps[] = array(
"name" => $matches[1][$i],
"id" => $matches[2][$i]
);
}
}
print_r($apps);