Re: [PHP] Novice question - please help

2002-02-11 Thread Adrian Murphy

use str_replace() instead of ereg_replace() ...in the same way described
- Original Message -
From: brendan conroy [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Monday, February 11, 2002 9:15 PM
Subject: [PHP] Novice question - please help


 Hi,
THANK YOU for reading this.I would really appreciate it if someone
could
 please email me if they know any easy way or an existing function for
 removing an unknown ammount of space characters from an array.

 Iam having an awful lot of trouble trying to remove multiple space
 characters from an array,

   ie.   x   +   y
 123456789

 where there are three or more spaces in a row(rep'd above by 234  678),
 basically weird user input.

 I have written code already, but I cant see where Ive gone wrong, here it
is
 if you care to look at it, and have a good chuckle, told you I was a
novice!
 I included the start page that allows you to see what the code does, in
you
 want to look at it.
 Thank you for your time, I'd really appreciate any replies!


 HTML
 BODY


 ?


 $x = 0;
 $ay=array();
 $g=array();
 $c = explode (' ', $a);


for($q=0;$q=count($c);$q++)
 {
 echofont color=green;
 echo$c[$q];
 echoHR;
 echo/font;
 }


 $c=array_reverse($c);


 for($w = 0;$wcount($c);$w++)

 {
 echo $w;
 $e=array_pop($c);
 if(($e == ' ')||($e == NULL))
 {

 echohi space;
 array_push($ay,$e);
 echoHR;
 }
 else
 {
 echohi no space;
 array_push($g,$e);

 }
 }



 echo(count($g));



 for($x=0;$x=(count($g));$x++)
 {
 echoBR;
 echo$g[$x];
 echoHR;
 }

 ?

 /BODY
 /HTML




 ==
 start page code
 ==



 html
 head
 titlenpage.php/title

 /head

 body bgcolor=#FF text=#00


 form action=newplan2.php method=post
 enter polynomial ? echo $i;? here:input type=text name=a

 input type=submit name=submit value=Submit Pols!



 /body
 /html




 _
 Chat with friends online, try MSN Messenger: http://messenger.msn.com


 --
 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] Novice question - Please Help

2002-01-30 Thread Jerry Verhoef (UGBI)

Take a look at split, explode

 -Original Message-
 From: brendan conroy [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, January 30, 2002 1:10 PM
 To: [EMAIL PROTECTED]
 Subject: [PHP] Novice question - Please Help
 
 
 Hi,
thanks for reading this. Ive looked at every php site and 
 cant find an 
 answer, youre my last hope!(ok so its not that serious, but 
 pretty close!).
 Could someone please email me and tell me how to split a string into 
 different arrays and save what they were split on?
 Also I cant get the sizeof function to work no matter what 
 syntax i use, i 
 think ive tried them all, do you have to include a library or 
 something in 
 your program to make it work?
 
 Thanks a million, this isint a frivilous question, I looked 
 everywhere 
 before i came here, thanks,
 
 
 
 Bren
 
 _
 Join the world's largest e-mail service with MSN Hotmail. 
 http://www.hotmail.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]
 


The information contained in this email is confidential and
may be legally privileged. It is intended solely for the 
addressee. Access to this email by anyone else is 
unauthorized. If you are not the intended recipient, any 
form of disclosure, production, distribution or any action 
taken or refrained from in reliance on it, is prohibited and 
may be unlawful. Please notify the sender immediately.

The content of the email is not legally binding unless 
confirmed by letter bearing two authorized signatures.

-- 
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] Novice question - Please Help

2002-01-30 Thread David Otton

On Wed, 30 Jan 2002 12:10:14 +, you wrote:

Could someone please email me and tell me how to split a string into 
different arrays

?
/* this is our start string */
$str = this:is:a:test:string;

/* split accepts a regular expression and a string, and
returns an array */
/* we could also use preg_split() or explode() */
$arr = split(':', $str);

/* for each element of $arr */
for ($i = 0; $i  sizeof($arr); $i++) {
/* display element */
echo($arr[$i]);
echo('br');
}

/* I know it's weird, but use sizeof() for arrays, and
strlen() for strings */

echo('$arr has ' . sizeof($arr) . ' elementsbr');

echo('$str has ' . strlen($str) . ' charactersbr');

?

and save what they were split on?

Not sure what this means.

Also I cant get the sizeof function to work no matter what syntax i use, i 
think ive tried them all, do you have to include a library or something in 
your program to make it work?

If the above doesn't work, then maybe there's something wrong with
your install.

djo


-- 
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]