how to replace whitespace with a character in a string php code example Example: php string replace space $journalName = preg_replace('/\s+/', '_', $journalName);