<?php
$str1 = "CN=CMPPDepartemental_Secretariat,OU=1 - Groupes de sécurité,OU=CMPP,OU=Pole,OU=Utilisateurs,DC=ricky,DC=fr";
$str2 = "CN=CMPPDepartemental_Direction,OU=1 - Groupes de sécurité,OU=CMPP,OU=Pole,OU=Utilisateurs,DC=ricky,DC=fr";
var_dump(find_by_keyword($str2, "CN="));
function find_by_keyword( $string, $keyword ) {
$array = explode(",",$string);
$found = [];
// Loop through each item and check for a match.
foreach ( $array as $string ) {
// If found somewhere inside the string, add.
if ( strpos( $string, $keyword ) !== false ) {
$found[] = substr($string, strlen($keyword));
}
}
return $found;
}
preferences:
28.86 ms | 407 KiB | 5 Q