Re: [PHP] trim() white space from record set

2004-07-22 Thread David Robley
On Thu, 22 Jul 2004 05:50, Msa wrote:

 aaah, simple for you..
 
 I have to fit that line into the following:
 
 $colauthor_rsResults = 0;
 if (isset($_GET['Author'])) {
   $colauthor_rsResults = (get_magic_quotes_gpc()) ? $_GET['Author'] :
 addslashes($_GET['Author']);
 }
 
 and don't know how to do that.also, I am using GET
 

So, $colauthor_rsResults is the field you want trimmed? Just do it after you
finish the If.

$colauthor_rsResults = 0;
if (isset($_GET['Author'])) {
  $colauthor_rsResults = (get_magic_quotes_gpc()) ? $_GET['Author'] :
addslashes($_GET['Author']);
}
$colauthor_rsResults =trim($colauthor_rsResults);

-- 
David Robley

Never enter a battle of wits unarmed.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] trim() white space from record set

2004-07-21 Thread John W. Holmes
msa wrote:
I created a search form with multiple search parameters.  It returns nothing
if there is a space after their text entry or if they hit return in the text
area.
$coltitle_rsResults = 0;
if (isset($_GET['Title'])) {
$_GET['title'] = trim($_GET['title']);
  $coltitle_rsResults = (get_magic_quotes_gpc()) ? $_GET['Title'] :
addslashes($_GET['Title']);
where do i put the trim?
See above. You have to assign the result of trim() to a variable. My 
crystal ball (it's back off of loan now) says that was the issue. :)

--
---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals  www.phparch.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] trim() white space from record set

2004-07-21 Thread Justin Patrin
On Wed, 21 Jul 2004 12:41:55 -0400, John W. Holmes
[EMAIL PROTECTED] wrote:
 msa wrote:
 
  I created a search form with multiple search parameters.  It returns nothing
  if there is a space after their text entry or if they hit return in the text
  area.
 
  $coltitle_rsResults = 0;
  if (isset($_GET['Title'])) {
 $_GET['title'] = trim($_GET['title']);
$coltitle_rsResults = (get_magic_quotes_gpc()) ? $_GET['Title'] :
  addslashes($_GET['Title']);
 
  where do i put the trim?
 
 See above. You have to assign the result of trim() to a variable. My
 crystal ball (it's back off of loan now) says that was the issue. :)
 

Ughdamn Perl and its auto-assign and $_ features. It makes people
assume things...


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] trim() white space from record set

2004-07-21 Thread msa
thanks for the helpthe syntax is wrong
somewhereparentasis.colonsI don't know where the error is


$coltitle_rsResults = 0;
if (isset($_GET['Title'])) {
$_GET['title'] = trim($_GET['title']);
$coltitle_rsResults = (get_magic_quotes_gpc()) ? $_GET['Title'] :
addslashes($_GET['Title']);

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] trim() white space from record set

2004-07-21 Thread melissa atchley
thanks guys...but with all of the  in the message, the syntax is not
coming through.

I have tried adding the trim() line in several ways and it isn't working.
can you help me with the exact syntax?

- Original Message - 
From: Justin Patrin [EMAIL PROTECTED]
To: John W. Holmes [EMAIL PROTECTED]
Cc: msa [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, July 21, 2004 1:12 PM
Subject: Re: [PHP] trim() white space from record set


 On Wed, 21 Jul 2004 12:41:55 -0400, John W. Holmes
 [EMAIL PROTECTED] wrote:
  msa wrote:
 
   I created a search form with multiple search parameters.  It returns
nothing
   if there is a space after their text entry or if they hit return in
the text
   area.
  
   $coltitle_rsResults = 0;
   if (isset($_GET['Title'])) {
  $_GET['title'] = trim($_GET['title']);
 $coltitle_rsResults = (get_magic_quotes_gpc()) ? $_GET['Title'] :
   addslashes($_GET['Title']);
  
   where do i put the trim?
 
  See above. You have to assign the result of trim() to a variable. My
  crystal ball (it's back off of loan now) says that was the issue. :)
 

 Ughdamn Perl and its auto-assign and $_ features. It makes people
 assume things...


 -- 
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder

 paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] trim() white space from record set

2004-07-21 Thread Justin Patrin
What exactly are you trying to do? trim() only rmeoves whitespace from
the beginning and end of a string. It doesn't work on a record / array
and it doesn't pull all whitespace from the string.

$str = 'whitespace before and after';
$trimmedStr = trim($str);
$noWhitespaceStr = preg_replace('/\s/', '', $str);

On Wed, 21 Jul 2004 13:54:22 -0400, melissa atchley
[EMAIL PROTECTED] wrote:
 thanks guys...but with all of the  in the message, the syntax is not
 coming through.
 
 I have tried adding the trim() line in several ways and it isn't working.
 can you help me with the exact syntax?
 
 
 
 - Original Message -
 From: Justin Patrin [EMAIL PROTECTED]
 To: John W. Holmes [EMAIL PROTECTED]
 Cc: msa [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Wednesday, July 21, 2004 1:12 PM
 Subject: Re: [PHP] trim() white space from record set
 
  On Wed, 21 Jul 2004 12:41:55 -0400, John W. Holmes
  [EMAIL PROTECTED] wrote:
   msa wrote:
  
I created a search form with multiple search parameters.  It returns
 nothing
if there is a space after their text entry or if they hit return in
 the text
area.
   
$coltitle_rsResults = 0;
if (isset($_GET['Title'])) {
   $_GET['title'] = trim($_GET['title']);
  $coltitle_rsResults = (get_magic_quotes_gpc()) ? $_GET['Title'] :
addslashes($_GET['Title']);
   
where do i put the trim?
  
   See above. You have to assign the result of trim() to a variable. My
   crystal ball (it's back off of loan now) says that was the issue. :)
  
 
  Ughdamn Perl and its auto-assign and $_ features. It makes people
  assume things...
 
 
  --
  DB_DataObject_FormBuilder - The database at your fingertips
  http://pear.php.net/package/DB_DataObject_FormBuilder
 
  paperCrane --Justin Patrin--
 
 
 !DSPAM:40feabc142245912817392!
 
 


-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] trim() white space from record set

2004-07-21 Thread Justin Patrin
On Wed, 21 Jul 2004 15:00:39 -0400, melissa atchley
[EMAIL PROTECTED] wrote:
 I have a search page with three parametersauthor, title and journal.
 
 I typed in heart in the title text area and hit the return button,
 thinking it would activate the search button.  it merely did a carriage
 return in the text area, then I hit the submit button.
 
 the result came back as null, as there is not title that has the word
 heart in it with a carriage return afterwards.  if I take our the return,
 it finds the heart articles.
 
 I tried a similar thing in the author section, putting a space after the
 author name...same empty results.
 
 I would like to fix that.
 

Ok, this is simple. Assuming you pass in author as the variable author
in POST...

$author = trim($_POST['author']);

 
 
 
 - Original Message -
 
  What exactly are you trying to do? trim() only rmeoves whitespace from
  the beginning and end of a string. It doesn't work on a record / array
  and it doesn't pull all whitespace from the string.
 
  $str = 'whitespace before and after';
  $trimmedStr = trim($str);
  $noWhitespaceStr = preg_replace('/\s/', '', $str);
 
  On Wed, 21 Jul 2004 13:54:22 -0400, melissa atchley
  [EMAIL PROTECTED] wrote:
   thanks guys...but with all of the  in the message, the syntax is not
   coming through.
  
   I have tried adding the trim() line in several ways and it isn't
 working.
   can you help me with the exact syntax?
  
  
  
   - Original Message -
   From: Justin Patrin [EMAIL PROTECTED]
   To: John W. Holmes [EMAIL PROTECTED]
   Cc: msa [EMAIL PROTECTED]; [EMAIL PROTECTED]
   Sent: Wednesday, July 21, 2004 1:12 PM
   Subject: Re: [PHP] trim() white space from record set
  
On Wed, 21 Jul 2004 12:41:55 -0400, John W. Holmes
[EMAIL PROTECTED] wrote:
 msa wrote:

  I created a search form with multiple search parameters.  It
 returns
   nothing
  if there is a space after their text entry or if they hit return
 in
   the text
  area.
 
  $coltitle_rsResults = 0;
  if (isset($_GET['Title'])) {
 $_GET['title'] = trim($_GET['title']);
$coltitle_rsResults = (get_magic_quotes_gpc()) ? $_GET['Title']
 :
  addslashes($_GET['Title']);
 
  where do i put the trim?

 See above. You have to assign the result of trim() to a variable. My
 crystal ball (it's back off of loan now) says that was the issue. :)

   
Ughdamn Perl and its auto-assign and $_ features. It makes people
assume things...
   
   
--
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder
   
paperCrane --Justin Patrin--
  
  
  
  
  
 
 
  --
  DB_DataObject_FormBuilder - The database at your fingertips
  http://pear.php.net/package/DB_DataObject_FormBuilder
 
  paperCrane --Justin Patrin--
 
 

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] trim() white space from record set

2004-07-21 Thread msa
aaah, simple for you..

I have to fit that line into the following:

$colauthor_rsResults = 0;
if (isset($_GET['Author'])) {
  $colauthor_rsResults = (get_magic_quotes_gpc()) ? $_GET['Author'] :
addslashes($_GET['Author']);
}

and don't know how to do that.also, I am using GET

Justin Patrin [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 On Wed, 21 Jul 2004 15:00:39 -0400, melissa atchley
 [EMAIL PROTECTED] wrote:
  I have a search page with three parametersauthor, title and journal.
 
  I typed in heart in the title text area and hit the return button,
  thinking it would activate the search button.  it merely did a carriage
  return in the text area, then I hit the submit button.
 
  the result came back as null, as there is not title that has the word
  heart in it with a carriage return afterwards.  if I take our the
return,
  it finds the heart articles.
 
  I tried a similar thing in the author section, putting a space after the
  author name...same empty results.
 
  I would like to fix that.
 

 Ok, this is simple. Assuming you pass in author as the variable author
 in POST...

 $author = trim($_POST['author']);

 
 
 
  - Original Message -
 
   What exactly are you trying to do? trim() only rmeoves whitespace from
   the beginning and end of a string. It doesn't work on a record / array
   and it doesn't pull all whitespace from the string.
  
   $str = 'whitespace before and after';
   $trimmedStr = trim($str);
   $noWhitespaceStr = preg_replace('/\s/', '', $str);
  
   On Wed, 21 Jul 2004 13:54:22 -0400, melissa atchley
   [EMAIL PROTECTED] wrote:
thanks guys...but with all of the  in the message, the syntax is
not
coming through.
   
I have tried adding the trim() line in several ways and it isn't
  working.
can you help me with the exact syntax?
   
   
   
- Original Message -
From: Justin Patrin [EMAIL PROTECTED]
To: John W. Holmes [EMAIL PROTECTED]
Cc: msa [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Wednesday, July 21, 2004 1:12 PM
Subject: Re: [PHP] trim() white space from record set
   
 On Wed, 21 Jul 2004 12:41:55 -0400, John W. Holmes
 [EMAIL PROTECTED] wrote:
  msa wrote:
 
   I created a search form with multiple search parameters.  It
  returns
nothing
   if there is a space after their text entry or if they hit
return
  in
the text
   area.
  
   $coltitle_rsResults = 0;
   if (isset($_GET['Title'])) {
  $_GET['title'] = trim($_GET['title']);
 $coltitle_rsResults = (get_magic_quotes_gpc()) ?
$_GET['Title']
  :
   addslashes($_GET['Title']);
  
   where do i put the trim?
 
  See above. You have to assign the result of trim() to a
variable. My
  crystal ball (it's back off of loan now) says that was the
issue. :)
 

 Ughdamn Perl and its auto-assign and $_ features. It makes
people
 assume things...


 --
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder

 paperCrane --Justin Patrin--
   
   
   
   
   
  
  
   --
   DB_DataObject_FormBuilder - The database at your fingertips
   http://pear.php.net/package/DB_DataObject_FormBuilder
  
   paperCrane --Justin Patrin--
 
 

 -- 
 DB_DataObject_FormBuilder - The database at your fingertips
 http://pear.php.net/package/DB_DataObject_FormBuilder

 paperCrane --Justin Patrin--

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] trim...

2003-11-26 Thread Luis Lebron

You need to strip the newlines. 

str_replace(\n,  , $body);


Luis
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, November 26, 2003 10:59 AM
To: [EMAIL PROTECTED]
Subject: [PHP] trim...


Why doesn't this work...?

$body = 
pblurb blah
phappy days
pend of text;

$body = trim($body);

$body now should output:
pblurb blah\nphappy days\npend of text but it doesn't...?

I'm using a text string in a javascript, adn it needs to be outbut on one 
line to work, yet this isn't doing it...
Any ideas?



*
The information contained in this e-mail message is intended only for 
the personal and confidential use of the recipient(s) named above.  
If the reader of this message is not the intended recipient or an agent
responsible for delivering it to the intended recipient, you are hereby 
notified that you have received this document in error and that any
review, dissemination, distribution, or copying of this message is 
strictly prohibited. If you have received this communication in error, 
please notify us immediately by e-mail, and delete the original message.
***



RE: [PHP] trim...

2003-11-26 Thread Ford, Mike [LSS]
On 26 November 2003 16:59, [EMAIL PROTECTED] contributed these pearls of wisdom:

 Why doesn't this work...?
 
 $body = 
 pblurb blah
 phappy days
 pend of text;
 
 $body = trim($body);
 
 $body now should output:
 pblurb blah\nphappy days\npend of text but it
 doesn't...? 

No it shouldn't -- it should output exactly what you've put into the string, minus any 
trailing spaces (of which there aren't any).  trim() has nothing to do with 
escapifying newline characters.  If you wnat your text output to javascript with \n in 
them, then that's exactly what you should put in them -- either that, or run a 
str_replace() to turn the newlines into \n sequences.

So:

   $body = pblurb blah\\nphappy days\\npend of text;
   echo $body

or

   $body = 
   pblurb blah
   phappy days
   pend of text;
   echo str_replace(\n, '\n', $body);


Cheers!

Mike

-- 
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] trim...

2003-11-26 Thread Dan Joseph
Hi,

  $body = 
  pblurb blah
  phappy days
  pend of text;
 
  $body = trim($body);
 
  $body now should output:
  pblurb blah\nphappy days\npend of text but it
  doesn't...?

does trim($body, 0x0A) fix your problem?  Do you want to strip everything
and leave \n in there?

-Dan Joseph

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] trim...

2003-11-26 Thread Justin Patrin
trim also gets rid of leading spaces...

Mike Ford wrote:
On 26 November 2003 16:59, [EMAIL PROTECTED] contributed these pearls of wisdom:


Why doesn't this work...?

$body = 
pblurb blah
phappy days
pend of text;
$body = trim($body);

$body now should output:
pblurb blah\nphappy days\npend of text but it
doesn't...? 


No it shouldn't -- it should output exactly what you've put into the string, minus any trailing spaces (of which there aren't any).  trim() has nothing to do with escapifying newline characters.  If you wnat your text output to javascript with \n in them, then that's exactly what you should put in them -- either that, or run a str_replace() to turn the newlines into \n sequences.

So:

   $body = pblurb blah\\nphappy days\\npend of text;
   echo $body
or

   $body = 
   pblurb blah
   phappy days
   pend of text;
   echo str_replace(\n, '\n', $body);
Cheers!

Mike

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] trim strings

2002-11-13 Thread Van Andel, Robert
You should be able to use substr().  

In your case, you would do
$newstring = substr($string,10);

Click the link for documentation.
http://www.php.net/manual/en/function.substr.php

Robbert van Andel 
=== 
Network Operator 
NW Regional Operations Center 
Charter Communications 
ROC Phone: 866-311-6646 
Desk Phone: 360-828-6727 
email: DL NW ROC 
=== 


-Original Message-
From: Greg [mailto:gregchagnon;hotmail.com]
Sent: Wednesday, November 13, 2002 9:15 AM
To: [EMAIL PROTECTED]
Subject: [PHP] trim strings


Hi-
Is there return a string with it's first 10  characters stripped?  Thanks.
_Greg



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


 The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited. If you received
this in error, please contact the sender and delete the material from all
computers. 





Re: [PHP] trim away x 1 number of spaces from a strin

2002-07-24 Thread Andrey Hristov


 $new = preg_replace('/[ ]{2,}/',$old);

HTH
Andrey

- Original Message -
From: Victor Spång Arthursson [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, July 24, 2002 12:05 PM
Subject: [PHP] trim away x  1 number of spaces from a strin


Hi!

Could someone help me with a replace that takes all occurances of  ,
that is space more than one, and replaces them with …?

Sincerely

Victor


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] trim away x 1 number of spaces from a strin

2002-07-24 Thread Evan Nemerson

php.net/str_replace


On Wednesday 24 July 2002 02:05 am, Victor Spång Arthursson wrote:
 Hi!

 Could someone help me with a replace that takes all occurances of  ,
 that is space more than one, and replaces them with …?

 Sincerely

 Victor

-- 
Go to Heaven for the climate, Hell for the company.

Samuel Clemens


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Trim a string

2001-05-06 Thread Jack Dempsey

if you're string is a variabe $address, then
eregi(http://,$address) will tell you if they've put in the http part, and
$address = substr($address,7);
will slice off and store the text after the http://

you'll find lots of different ways to do this...whatever suits you, go for
it...

-jack

-Original Message-
From: Kyle Mathews [mailto:[EMAIL PROTECTED]]
Sent: Sunday, May 06, 2001 4:46 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Trim a string


Hello:

I have a signup form that asks for a website address.
I don't need them to put in the http://, but I'm thinking that some will try
anyway.
Is there a way to check for this and remove it when the user submits the
form?

Thanks,
Kyle
[EMAIL PROTECTED]
http://www.thedip.net



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Trim a string

2001-05-06 Thread Jason Lotito

 -Original Message-
 From: Kyle Mathews [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, May 06, 2001 4:46 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Trim a string
 
 
 Hello:
 
 I have a signup form that asks for a website address.
 I don't need them to put in the http://, but I'm thinking that 
 some will try
 anyway.
 Is there a way to check for this and remove it when the user submits the
 form?
 
 Thanks,
 Kyle
 [EMAIL PROTECTED]
 http://www.thedip.net


str_replace()

$string = http://www.foo.com;;

$string = str_replace(http://,,$string);

echo $string;

Will echo out:

www.foo.com

For more information:
http://www.php.net/str-replace

Jason Lotito
Webmaster Newbie Network - http://www.NewbieNetwork.net
EIC PHP Weekly Newsletter - http://www.newbienetwork.net/ciao.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Trim a string

2001-05-06 Thread Kyle Mathews

Thanks, that worked great.

- Kyle



Jack Dempsey [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 if you're string is a variabe $address, then
 eregi(http://,$address) will tell you if they've put in the http part,
and
 $address = substr($address,7);
 will slice off and store the text after the http://

 you'll find lots of different ways to do this...whatever suits you, go for
 it...

 -jack

 -Original Message-
 From: Kyle Mathews [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, May 06, 2001 4:46 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Trim a string


 Hello:

 I have a signup form that asks for a website address.
 I don't need them to put in the http://, but I'm thinking that some will
try
 anyway.
 Is there a way to check for this and remove it when the user submits the
 form?

 Thanks,
 Kyle
 [EMAIL PROTECTED]
 http://www.thedip.net



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] trim string - try array/join()

2001-03-22 Thread Jeff Armstrong

You have a hidden issue with the extra trailing comma.
When I want a list of things, I prefer this approach:

$db = mysql_select_db("tkenet_db");
$query = "SELECT app_name,status FROM approval_list where doc_no='6'";
$result = mysql_query($query,$db);

$ccs=array();
while( $data = mysql_fetch_row($result) ){ 
  $ccs[] = trim($h-get_email($data[0]));
}
$cc = join(",",$ccs);

It seems happy with large arrays (10,000s).

Regards
Jeff

-Original Message-
From: Mark Maggelet [mailto:[EMAIL PROTECTED]]
Sent: Thursday, March 22, 2001 12:20 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: Re: [PHP] trim string


On Wed, 21 Mar 2001 18:09:47 +0800, Wen Ni Leong 
([EMAIL PROTECTED]) wrote:
I need help in this basic string function.
I query from the database by using while loop and the result in in
array.  I separated them by using "," .

I want at the end of the string to be trim off.  Unfortunately I 
tried
all the string function such as chop,trim and substr but they seem 
like
can't manage to trim the end of the string.  Please help me.

my coding are:

$db = mysql_select_db("tkenet_db");
$query = "SELECT app_name,status FROM approval_list where 
doc_no='6'";
$result = mysql_query($query,$db);
while($data = mysql_fetch_row($result)){ 

 $cc .= $h-get_email($data[0]).",";

   if ($data[1] != 'Y')
 { $all_yes = 1;}
  }
 trim($cc);


this doesn't do anything to $cc, you have to catch the return value:
$cc=trim($cc);


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] trim string

2001-03-21 Thread Keith Vance

You might be able to use substr.
http://www.php.net/substr

K E I T H  V A N C E
Software Engineer
n-Link Corporation

On Wed, 21 Mar 2001, Wen Ni Leong wrote:

 I need help in this basic string function.
 I query from the database by using while loop and the result in in
 array.  I separated them by using "," .

 I want at the end of the string to be trim off.  Unfortunately I tried
 all the string function such as chop,trim and substr but they seem like
 can't manage to trim the end of the string.  Please help me.

 my coding are:

 $db = mysql_select_db("tkenet_db");
 $query = "SELECT app_name,status FROM approval_list where doc_no='6'";
 $result = mysql_query($query,$db);
 while($data = mysql_fetch_row($result)){

  $cc .= $h-get_email($data[0]).",";

if ($data[1] != 'Y')
  { $all_yes = 1;}
   }
  trim($cc);



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] trim string

2001-03-21 Thread James Moore



 -Original Message-
 From: Wen Ni Leong [mailto:[EMAIL PROTECTED]]
 Sent: 21 March 2001 10:10
 To: [EMAIL PROTECTED]
 Subject: [PHP] trim string
 
 
 I need help in this basic string function.
 I query from the database by using while loop and the result in in
 array.  I separated them by using "," .
 
 I want at the end of the string to be trim off.  Unfortunately I tried
 all the string function such as chop,trim and substr but they seem like
 can't manage to trim the end of the string.  Please help me.

http://www.php.net/rtrim

James

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] trim string

2001-03-21 Thread Gary Huntress

Perform the trim as part of the query:

"Select rtrim(app_name) , rtrim( status) from approval_list where
doc_no='6'"


"Wen Ni Leong" [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 I need help in this basic string function.
 I query from the database by using while loop and the result in in
 array.  I separated them by using "," .

 I want at the end of the string to be trim off.  Unfortunately I tried
 all the string function such as chop,trim and substr but they seem like
 can't manage to trim the end of the string.  Please help me.

 my coding are:

 $db = mysql_select_db("tkenet_db");
 $query = "SELECT app_name,status FROM approval_list where doc_no='6'";
 $result = mysql_query($query,$db);
 while($data = mysql_fetch_row($result)){

  $cc .= $h-get_email($data[0]).",";

if ($data[1] != 'Y')
  { $all_yes = 1;}
   }
  trim($cc);







 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] trim string

2001-03-21 Thread Mark Maggelet

On Wed, 21 Mar 2001 18:09:47 +0800, Wen Ni Leong
([EMAIL PROTECTED]) wrote:
I need help in this basic string function.
I query from the database by using while loop and the result in in
array.  I separated them by using "," .

I want at the end of the string to be trim off.  Unfortunately I
tried
all the string function such as chop,trim and substr but they seem
like
can't manage to trim the end of the string.  Please help me.

my coding are:

$db = mysql_select_db("tkenet_db");
$query = "SELECT app_name,status FROM approval_list where
doc_no='6'";
$result = mysql_query($query,$db);
while($data = mysql_fetch_row($result)){

 $cc .= $h-get_email($data[0]).",";

   if ($data[1] != 'Y')
 { $all_yes = 1;}
  }
 trim($cc);


this doesn't do anything to $cc, you have to catch the return value:
$cc=trim($cc);


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




RE: [PHP] Trim an array?

2001-02-03 Thread PHPBeginner.com

a simple

snip
for($i=0; $isizeof($array); $++)
$array[$i]=trim($array[$i]);
/snip

will do the trick

 Cheers,

 Maxim Maletsky
 Founder, Chief Developer

 PHPBeginner.com (Where PHP Begins)
 [EMAIL PROTECTED]
 www.phpbeginner.com



-Original Message-
From: Thomas Deliduka [mailto:[EMAIL PROTECTED]]
Sent: Saturday, February 03, 2001 7:32 AM
To: PHP List
Subject: [PHP] "Trim" an array?


I looked through the archives and couldn't find anything on this.

I have a web form which takes 9 values to create a definition for a table
that would have up to 9 columns.

I made the table so that each form field is submitted as an array so that I
can simply step through each value and create the table definition, so:

input type=text name="tblcol[]"  (duplicated 9 times)

Now, when I submit the form the resulting array always has 9 elements and
some of those will be empty.

I would like to do error checking in case people didn't fill anything at all
so I thought using if (!count($tblcol)) { But that doesn't work since it
always has 9 elements.

Is there a way to find out if an array contains no values even though it has
elements?  Sort of like a trim() function on an array to destroy the
elements in the array that are empty.

Is it possible?
--

Thomas Deliduka
IT Manager
 -
New Eve Media
The Solution To Your Internet Angst
http://www.neweve.com/



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Trim an array?

2001-02-02 Thread Mark Maggelet

On Fri, 02 Feb 2001 17:31:43 -0500, Thomas Deliduka
([EMAIL PROTECTED]) wrote:
I looked through the archives and couldn't find anything on this.

I have a web form which takes 9 values to create a definition for a
table
that would have up to 9 columns.

I made the table so that each form field is submitted as an array so
that I
can simply step through each value and create the table definition,
so:

input type=text name="tblcol[]"  (duplicated 9 times)

Now, when I submit the form the resulting array always has 9
elements and
some of those will be empty.

I would like to do error checking in case people didn't fill
anything at all
so I thought using if (!count($tblcol)) { But that doesn't work
since it
always has 9 elements.

Is there a way to find out if an array contains no values even
though it has
elements?  Sort of like a trim() function on an array to destroy the
elements in the array that are empty.

Is it possible?

while(list($key,$value)=each($array)){
if(empty($value)) unset $array[$key];
}


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]