Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Spaces (https://forums.graalonline.com/forums/showthread.php?t=76549)

Kyranki 08-28-2007 05:47 PM

Spaces
 
PHP Code:

public function removeAllSpaces(text) {
  
temp.toks text.tokenize();
  for (
temp.str temp.toks) {
    if (
temp.str == " ") {
      continue;
    }
    
temp.out @= temp.str;
  }
  return 
temp.out.trim();
}
//#CLIENTSIDE
public function removeAllSpaces(text) {
  
temp.toks text.tokenize();
  for (
temp.str temp.toks) {
    if (
temp.str == " ") {
      continue;
    }
    
temp.out @= temp.str;
  }
  return 
temp.out.trim();


This removes all spaces everywhere on a join. A simple usage of this would be something like.

PHP Code:

function onCreated() {
  
join("util_spaces");
  
temp.string " Lollin @ Chompy";
  echo(
removeAllSpaces(temp.string));


^ That would echo: "Lollin@Chompy";
Just for some of those minor irritations that are too minor to add a built in function for.

Twinny 08-28-2007 06:04 PM

I don't think spaces are included in the return from tokenize(); In the end, you could easily loop the array without the need to check for spaces.

Kyranki 08-28-2007 06:11 PM

Err, well I'll check it out later. I think it is tho, not sure.

Edit: Actually you're right because space is the delimiter. Thanks Twinny. ;P

Chompy 08-28-2007 06:20 PM

<3

PHP Code:

public function removeSpaces(str) {
  
temp.out 0;
  for(
temp.str.tokenize()) out @= t;
  return 
out;


Oh, and lol back at you :p
<3

Kyranki 08-29-2007 03:27 AM

Quote:

Originally Posted by Chompy (Post 1344218)
<3

PHP Code:

public function removeSpaces(str) {
  
temp.out 0;
  for(
temp.str.tokenize()) out @= t;
  return 
out;


Oh, and lol back at you :p
<3

<3


All times are GMT +2. The time now is 11:59 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.