Jump to content


Problem with space-[php]


5 replies to this topic

#1 liveman

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Location:New Jersey

Posted 13 November 2005 - 11:06 PM

Hello,
Ok well I created a script for AIM to log who clicked the button...ok well It works great with 1 exception...whenever there is a space it messes it up, and only puts the letters before the space...so I was thinking of ways to defeat that problem.

The first thing is to use ereg function, but one problem...what would I look for &nsbp; ? or another thing...that calls the space :D ok...if anyone has any other suggestions..please tell me!

#2 tiki

    Young Padawan

  • Members
  • Pip
  • 259 posts
  • Gender:Male
  • Location:California

Posted 13 November 2005 - 11:49 PM

Try   ?

#3 liveman

    Young Padawan

  • Members
  • Pip
  • 246 posts
  • Location:New Jersey

Posted 14 November 2005 - 06:46 AM

Ok, well what I found out is that its aims problem...in a normal broswer it puts %20 in for spaces, but on aim It cuts words....so when it clicks to send the info it only sends up to the space :D so that means I need to get there screenname in there...anyone know how I can do that?

#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 14 November 2005 - 05:26 PM

  is an htmlentity. It's short for non-breaking space. It's translated by the browser, php sees it exactly as-is.

ereg() does have a pattern to automatically match spaces (i believe its [:space:], but i don't use that form of regex, so i don't know).
So why not try replacing the spaces with an underscore (_)? That'd be easiest... unless underscores are a bigger part of it.

#5 kcd

    Young Padawan

  • Members
  • Pip
  • 10 posts

Posted 17 November 2005 - 09:39 AM

dosent just normal space bar work.
it dose for me.

Edited by kcd, 17 November 2005 - 09:41 AM.


#6 Sicloan

    Young Padawan

  • Members
  • Pip
  • 31 posts

Posted 17 November 2005 - 04:04 PM

just use a replace(); functions
$string = "hello bob!";

$string = str_replace(" ","_",$string);

output = "hello_bob!";

I also suggest taking a look at the ereg_replace(); php function page...

http://us2.php.net/m...reg-replace.php

Edited by Sicloan, 17 November 2005 - 04:04 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users