$name = str_replace(' ', '_', $name);
Answer from Tim Fountain on Stack OverflowMefancy
mefancy.com › textchange › replace-space-underscore
Replace Spaces with Underscores (and more) - Online Text Tool | MeFancy
Programming Variables: Most programming languages (Python, C, PHP) do not allow spaces in variable names. user id becomes user_id (snake_case). Data Cleaning: Standardizing data formats for database imports often requires replacing spaces with specific delimiters. Enter Text: Paste your text into the input box or drag and drop a file. Select Mode: Choose whether you want to replace spaces with underscores...
IQCode
iqcode.com › code › php › php-replace-space-with-underscore
php replace space with underscore Code Example
October 7, 2021 - Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond. Sign up · Develop soft skills on BrainApps Complete the IQ Test ... php remove underscore from string and put space replace space with underscore and slash with , php replace all space with underscore ...
Grabthiscode
grabthiscode.com › php › php-replace-space-with-underscore
Php replace space with underscore - code example - GrabThisCode.com
php replace spaces with dash · php convert words with spaces to camelcase · php string underscore into camelcase · php insert hyphen into spaces in string · php convert spaces to underscores · php replace \n by <br> remove empty spaces php · php split string along spaces ·
Top answer 1 of 4
209
I'll suggest that you use this as it will check for both single and multiple occurrence of white space (as suggested by Lucas Green).
$journalName = preg_replace('/\s+/', '_', $journalName);
instead of:
$journalName = str_replace(' ', '_', $journalName);
2 of 4
23
Try this instead:
$journalName = preg_replace('/\s+/', '_', $journalName);
Explanation: you are most likely seeing whitespace, not just plain spaces (there is a difference).
SitePoint
sitepoint.com › php
How to replace space " " with underscore "_" - PHP - SitePoint Forums | Web Development & Design Community
January 11, 2014 - I need a little help. I have created the below script. A form that save its info to my database and a long with that it create some (2 on different paths) folders on the server. My issue is that in the form under ”folder” you can type the name of the folder you want to create along with ...
Snipplr
snipplr.com › view › 19793 › how-to-replace-spaces-in-a-file-name-with-underscores
How to replace spaces in a file name with underscores - PHP Snipplr Social Repository
How to access a JSON in PHP easy (like a JSON recordset with multiple fields) 2627 · How to replace the default WordPress “W†logo in the administrative header with a custom alternative · 3330 · How to read from a file in Java · 2731 · Extjs - how to select a row in a grid with a right-mouse click · 867 · Convert spaces in file names to underscores ·
ItSolutionstuff
itsolutionstuff.com › post › how-to-replace-underscore-with-space-in-pythonexample.html
How to Replace Underscore with Space in Python? - ItSolutionstuff.com
October 30, 2023 - # Python string replace underscore with space myString = myString.replace("_", " ") print(myString) ... Hello This is ItSolutionStuff.com This is awesome. I hope it can help you... ... I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.📺 Subscribe on YouTube
w3resource
w3resource.com › python-exercises › re › python-re-exercise-23.php
Python: Replace whitespaces with an underscore and vice versa - w3resource
July 28, 2025 - Write a Python program to replace whitespaces with an underscore and vice versa. ... import re text = 'Python Exercises' text =text.replace (" ", "_") print(text) text =text.replace ("_", " ") print(text) ... Write a Python program to replace all spaces in a string with underscores and then convert underscores back to spaces.
ItSolutionstuff
itsolutionstuff.com › post › how-to-replace-whitespace-with-underscore-in-pythonexample.html
How to Replace Whitespace with Underscore in Python? - ItSolutionstuff.com
October 30, 2023 - # Python string replace whitespace with underscore myString = myString.replace(" ", "_") print(myString) ... I hope it can help you... ... I'm a full-stack developer, entrepreneur, and founder of ItSolutionStuff.com. Passionate about PHP, Laravel, JavaScript, and helping developers grow.📺 Subscribe on YouTube
Finxter
blog.finxter.com › home › learn python blog › how to replace whitespaces with underscores
How to Replace Whitespaces with Underscores - Be on the Right Side of Change
July 22, 2022 - This method uses Python’s built-in string library and calls the replace() function to replace each whitespace with the underscore character.
Stack Exchange
wordpress.stackexchange.com › questions › 307438 › replace-dash-and-underscore-with-space
plugins - Replace Dash (-) and Underscore ( _ ) with Space - WordPress Development Stack Exchange
$string = str_replace( array( '-', '_' ), ' ' , $file['name'] );. But remember that these changes will disappear after plugin update. ... did'nt work. the result is text1-text2-10212-etc_125.jpg. if I remove a space the result is : ...
Savecode
savecode.net › code › php › php+replace+space+with+underscore
php replace space with underscore - SaveCode.net
July 13, 2020 - $str = str_replace(' ', '_', $str);
YouTube
youtube.com › watch
Replace Space with Underscore in Python - YouTube
Replace Space with Underscore using Pythonhttps://codingdiksha.com/python-replace-space-with-underscore/#python----------------------------------------------...
Published: December 17, 2021
Top answer 1 of 4
42
You can use the array_map function.
function modify($str) {
return ucwords(str_replace("_", " ", $str));
}
Then in just use the above function as follows:
$states=array_map("modify", $old_states)
2 of 4
4
Need to use array_map function like as
$state = array("gujarat","andhra_pradesh","madhya_pradesh","uttar_pradesh");
$state = array_map(upper, $state);
function upper($state){
return str_replace('_', ' ', ucwords($state));
}
print_r($state);// output Array ( [0] => Gujarat [1] => Andhra pradesh [2] => Madhya pradesh [3] => Uttar pradesh )
Stack Exchange
wordpress.stackexchange.com › questions › 239580 › replace-underscore-on-space
php - Replace Underscore (_) on Space ( ) - WordPress Development Stack Exchange
September 17, 2016 - I use the plugin "Auto Post With Image Upload" For example I load an image with name "Image_Name" then plugin creates a post with name "Image_Name" Now the question: How to remove Underscore (_) in post title Tell me "where to dig"? I know that there are such a function "str_replace". Where apply it? Here is a piece of code: $postData = array( 'post_title' => $attachment->post_title, 'post_type' => 'post', 'post_content' => $image_tag, 'post_category' => array('0'), 'post_status' => 'publish' ); P.S. I not quite understand php ·