PHP text replace? ( endings )
original string: $text = "aaaa aaaasomething someaaaa aaaa 89aaaa aaaathis"
final result i need: $textresult = "aaaa aaaasomething some4a aaaa 894a aaaathis"

I mean: I want to replace any string on the text that ends with aaaa to 4a. But only if it is an ending and not an isolated string like aaaa or a string that starts with aaaa.

I presume str_replace or preg_replace could eventually do this in a single code line but do not have idea how to do it.

Thanks in advance!

PHP text replace? ( endings )
===

original string: $text = "aaaa aaaasomething someaaaa aaaa 89aaaa aaaathis"
final result i need: $textresult = "aaaa aaaasomething some4a aaaa 894a aaaathis"

I mean: I want to replace any string on the text that ends with aaaa to 4a. But only if it is an ending and not an isolated string like aaaa or a string that starts with aaaa.

I presume str_replace or preg_replace could eventually do this in a single code line but do not have idea how to do it.

Thanks in advance!
