Not 100% sure of what you're trying to do but this would grab the values from the above string:
\[img width=(\d*) height=(\d*)\]
so this:
PHP Code:
$subject = '[img width=320 height=217]';
$find = '/\[img width=(\d*) height=(\d*)\]/im';
$replace = 'width=\1 and height=\2';
$result = preg_replace($find, $replace , $subject);
would give you:
width=320 and height=217