<?php
$nomes = ['Diretoria: (aprovação 23, de 2014)',
'Diretoria: (aprovação 42, de 2015)',
'Diretoria: (aprovação 70, de 2016)'];
$spans = [];
foreach ($nomes as $nome) {
if (preg_match('/\(aprovação (\d+), de (\d+)\)/', $nome, $retorno) !== false) { $num = $retorno[1];
$ano = $retorno[2];
$spans[] = "Diretoria: (aprovação <span class=\"caixa_$num\">$num</span>, de <span class=\"ano_$ano\">$ano<span>)";
}
}
foreach ($spans as $span) {
echo $span . "\n";
}
PD9waHAKCiRub21lcyA9IFsnRGlyZXRvcmlhOiAoYXByb3Zhw6fDo28gMjMsIGRlIDIwMTQpJywKICAgICAgICAgICdEaXJldG9yaWE6IChhcHJvdmHDp8OjbyA0MiwgZGUgMjAxNSknLAogICAgICAgICAgJ0RpcmV0b3JpYTogKGFwcm92YcOnw6NvIDcwLCBkZSAyMDE2KSddOwogCiRzcGFucyA9IFtdOyAgICAgICAKCmZvcmVhY2ggKCRub21lcyBhcyAkbm9tZSkgewoJaWYgKHByZWdfbWF0Y2goJy9cKGFwcm92YcOnw6NvIChcZCspLCBkZSAoXGQrKVwpLycsICRub21lLCAkcmV0b3JubykgIT09IGZhbHNlKSB7CgkJJG51bSA9ICRyZXRvcm5vWzFdOwoJCSRhbm8gPSAkcmV0b3Jub1syXTsKCQkKCQkkc3BhbnNbXSA9ICJEaXJldG9yaWE6IChhcHJvdmHDp8OjbyA8c3BhbiBjbGFzcz1cImNhaXhhXyRudW1cIj4kbnVtPC9zcGFuPiwgZGUgPHNwYW4gY2xhc3M9XCJhbm9fJGFub1wiPiRhbm88c3Bhbj4pIjsKCX0KfQoKZm9yZWFjaCAoJHNwYW5zIGFzICRzcGFuKSB7CgllY2hvICRzcGFuIC4gIlxuIjsKfQ==