php replace empty space with new line code example Example: php string replace space $journalName = preg_replace('/\s+/', '_', $journalName);