$totalWords = str_word_count(strip_tags($input));
$words = round($totalWords / 2);
$input = preg_replace('#^(.{$words}\S*?) #', "$1{$insert}", $input);
<?php
$text = 'John draw real poor on call my from. May she mrs furnished discourse extremely.';
function putInMiddle(string $text, string $word): string
{
$middlePosition = (int) strlen($text) / 2;
$middleSpacePosition = strrpos($text, ' ', -$middlePosition);
return substr_replace($text, ' ' . $word, $middleSpacePosition, 0);
}
echo putInMiddle($text, 'MY_MIDDLE_WORD');