Underdog Underdog - 1 year ago 77
HTML Question

ignore the characters contained in the database value in php

For example, I have a database table as follows :

enter image description here

I want to show lname value in html but by eliminating the " Mr. " without changing the values ​​contained in the database . is there any way to do this using a php script ?

mnv mnv
Answer Source

Use preg_replace():

echo preg_replace('/(mr\.\s+|ms.\s+)(.*)/ui', '$2', 'Mr. Bean');

// Mr. Bean -> Bean
// Bean -> Bean
// Ms. Stone -> Stone
// Jack Bean -> Jack Bean
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download