2 quick questions
Posted: Tue Jul 25, 2006 5:25 pm
New to PHP and have a few basic questions.
How do I strip varaiables of their "return" character.
For example if I'm reading in from a text file (1 word per line) the varaiable would look like this:
test\n
(or test^M under windows or whatever).
In perl I can just do a "chomp($var)" and it cleans it up nice and neat. What is the function in PHP to do this?
Also how do I do regex compares in PHP?
For example, in Perl, I could do something like this
Would output:
Found Date: Jul 07 2005
How do I do that in PHP... it doesn't have the =~ or !~ expressions?!?
Thanks!
How do I strip varaiables of their "return" character.
For example if I'm reading in from a text file (1 word per line) the varaiable would look like this:
test\n
(or test^M under windows or whatever).
In perl I can just do a "chomp($var)" and it cleans it up nice and neat. What is the function in PHP to do this?
Also how do I do regex compares in PHP?
For example, in Perl, I could do something like this
Code: Select all
if ($string =~ /\w{1,3}\s\d{2}\s200[5,6]/) {
print ("Found Date: $string\n"); }Found Date: Jul 07 2005
How do I do that in PHP... it doesn't have the =~ or !~ expressions?!?
Thanks!