-Original Message-
From: David Robley [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 13, 2002 3:25 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Re: converting C to PHP
In article 6416776FCC55D511BC4E0090274EFEF508A46F@EXCHANGE,
[EMAIL PROTECTED] says...
I'm converting some C functions to PHP and have come across this:
int skipf(..., char *format)
{
/* ... */
cp = format;
char *cp, *cp2;
multiplier = strtol(cp, cp2, 10);
/* ... */
}
How can I implement this line in PHP ?
multiplier = strtol(cp, cp2, 10);
Oh, and an example of format is 12L20W2P
Non C programmer volunteers suggsetion. I looked at strtol in the C docs
and I don't quite understand exactly what it does. But I wonder if intval
would be a starting point to try and get the result I think you want?
--
David Robley
Temporary Kiwi!
Quod subigo farinam
Just to crarify - what I need to get back is the first number and the first
letter after that number (which can be L, P, or W). So in the example
I gave, I'll need to get back 12 and L
What I settled on is:
ereg(([0-9]*)([LPW]), $format, $bits);
list(, $cnt, $skip) = $bits;
But maybe there's a better way ??
Martin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php