Reputation: 125
I have multiple string which contains HP16SDA305009, HP16JDA305009,HP16SWA305009
I need to get only SDA, JDA or SWA how can I achieve that
Upvotes: 1
Views: 32
Reputation: 125
$a= 'HP16JDA305009';
$char = substr($a, 4, -3);
echo $gen = substr($char, 0, 3);
Upvotes: 0
Reputation: 978
$var = "HP16SDA305009";
$result = substr($var, 0, -6);
echo $result = substr($result, 4, 3);
Upvotes: 1