How to replace some words,numbers,characters

In my database many posts has some characters like :

[media id=468 width=660 height=440]

With php i want to get media id (the number) and replace it with another function, also after taking the id, dont want that [media id=468 width=660 height=440] to be shown at my posts in html.

Please can some one help with this ? Thank you a lot

See how this goes for you

$replace     = '[media id=468 width=660 height=440]';
$replacement = preg_replace('/id\\=([0-9]+)/i', '', $replace);

echo 'Original: ' . $replace . '<br>Replaced: ' . $replacement;

Thank you

No problem, glad to help :slight_smile: