I'm giving an example so you can understand what I want to achieve. I got this titles:
$t1 = "Disposizione n. 158 del 28.1.2012";
$t2 = "Disposizione n.66 del 15.1.2006";
$t3 = "Disposizione f_n_66 del 15.1.2001";
$t4 = "Disposizione numero 66 del 15.1.2018";
$t5 = "Disposizione nr. 66 del 15.1.2017";
$t6 = "Disposizione nr_66 del 15.1.2016";
$t7 = "Disposizione numero_66 del 15.1.2005";
Until now I had tried:
$output = explode(' ', $t1);
foreach ($output as $key => $value) {
if($value == 'n.' || $value == 'numero' || $value == 'n' || $value == 'nr' || $value == 'nr.') {
$number= $output[($key+1)];
break;
}
}
print_r($attoNumero);
But this is a limited solution because it does not work on all titles. How can I use Regex
,explode
,str_split
, or anything else to achieve this?