Replacing spaces in an array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
goblinhybrid
Forum Newbie
Posts: 8
Joined: Tue Dec 09, 2003 2:41 pm

Replacing spaces in an array

Post by goblinhybrid »

how do i replace a space in an array with nothing??
thanks
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

Code: Select all

<?php

$array[] = "Text With Space One";
$array[] = "Text With Space Two";

foreach($array as $key => $value)
$array[$key] = str_replace(" ", "", $value);

?>
Post Reply