unwanted spaces in array

here is my code...

$cuswords = file( "cuswords.txt");
$array_size = sizeof($cuswords);
 for($i=0; $i<$array_size; $i++) {
     $cuswords[$i] = str_replace("\n","",$cuswords[$i]);
 /*testing array*/
 echo $cuswords[$i];}

i want to test this array against strings.... but when i use the test print i see that the values are printed "blah blah blah" while they should be stored as BlahBlahBlah with no spaces...
please help....

The text file is in the form of


if I understand correctly with the $value = file() command each new line is read as a new value into the array

thanx everyone....

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I think this has to do with your string replace arguments.
Assuming the text in your txt file is as follows:
"Blah bla bla"
(so on one line separated by spaces)...

Instead of "\n" you should then replace just " " with "".

By the way, if the text in your textfile is arranged in an other way, please post it so we can do some tests ourselves.

RainAuthor Commented:
Edited text of question.
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

what about:
$cuswords[$i] = str_replace('\n','',$cuswords[$i]);

coz the length of $cuswords[$i]is only 1
$cuswords[$i] = str_replace('\n','',$cuswords[$i]);
would be wrong. [ you guess why : hint ' != " ]
What I think is either :
1. you have some DOS text file, so the line delimiter is \r\n
you replace only the \n. Then when outputed in HTML(I guess)
you see the \r as a space. Try replacing "\r\n"
2 . or , the echo also sends a \n.

But, I don't see the meaning. What are you trying to compare?
the whole text in the file? Then just do
$all = file ('mytextfile.txt');
$all = implode ("",$all);
$all = str_replace ("\n","",$all);
Header("Content-Type: text/plain");
echo "-->$all<--" ; //to see if it is the expected string;
$cuswords = file( "cuswords.txt");
$array_size = sizeof($cuswords);
 for($i=0; $i<$array_size; $i++)
    $cuswords[$i] = trim(str_replace("\n","",$cuswords[$i]));

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.