jeeeee jeeeee - 5 months ago 9
PHP Question

String manipulation in php. Get specific word inside a string

I have a string for example.

"Name: Juan
Address: Here
Postal Code: M1P 4T7"

Now in this string the only thing i need is the "M1P 4T7" How do I get that?

Thank you very much!

Answer
<?php
$string = 'Name: Juan Address: Here Postal Code: M1P 4T7';
$new = ltrim(explode(':', $string)[3]);
var_dump($new); // string(7) "M1P 4T7"