By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,045 Members | 1,305 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,045 IT Pros & Developers. It's quick & easy.

translation from VB (int and val)

P: n/a
I am taking this from VB, but what are int and val in PHP?

$i = Int(Val(substr($code, 3, 3)) / 100) * 100;

In case you dont know VB
Int - truncates the numner (i looked for trunc already)
Val - string to number

Sonnich

PS: jep I have realised I can to the thing above simpler.

Jun 16 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
And while I am at it:

Format - when I want 35 to be shown as 0035 ?

Is there a way to look for files. eg c:\here\*.pdf (as Dir in VB)?
Sonnich wrote:
I am taking this from VB, but what are int and val in PHP?

$i = Int(Val(substr($code, 3, 3)) / 100) * 100;

In case you dont know VB
Int - truncates the numner (i looked for trunc already)
Val - string to number

Sonnich

PS: jep I have realised I can to the thing above simpler.


Jun 16 '06 #2

P: n/a
Hi,

Int(a) = (int)$a
Val(a) - you do not need it because PHP converts numbers to strings
automatically.
Format - consider http://php.net/printf or http://php.net/sprintf

Sincerely,
Alexander
http://www.alexatnet.com/

Sonnich wrote:
And while I am at it:

Format - when I want 35 to be shown as 0035 ?

Is there a way to look for files. eg c:\here\*.pdf (as Dir in VB)?
Sonnich wrote:
I am taking this from VB, but what are int and val in PHP?

$i = Int(Val(substr($code, 3, 3)) / 100) * 100;

In case you dont know VB
Int - truncates the numner (i looked for trunc already)
Val - string to number

Sonnich

PS: jep I have realised I can to the thing above simpler.


Jun 16 '06 #3

P: n/a
Sonnich - go get a copy of the PHP manual and read it - its free and even
avilable in .chm format. You can download it from
http://www.php.net/docs.php

Sonnich wrote:
And while I am at it:

Format - when I want 35 to be shown as 0035 ?

printf()
Is there a way to look for files. eg c:\here\*.pdf (as Dir in VB)?
Yes but the builtin does not implicitly support recursion or wildcards - you
need to implement them for yourself. Alternatively you can run external
programs and read the results back into PHP.

Sonnich wrote:
I am taking this from VB, but what are int and val in PHP?
Largely redundant since it is dynamically typed. But it does provide ceil(),
floor() and round() along with type casting.

$i = Int(Val(substr($code, 3, 3)) / 100) * 100;


Assuming that you may have decimals within the 3 chars:

$i = (integer)substr($code, 3, 3);

C.
Jun 16 '06 #4

P: n/a
BTW, http://www.wiki.cc/php/RecursiveDirectoryIterator may be exact
match when you need to iterate through files in folders.

Sincerely,
Alexander
http://www.alexatnet.com/

Colin McKinnon wrote:
Sonnich - go get a copy of the PHP manual and read it - its free and even
avilable in .chm format. You can download it from
http://www.php.net/docs.php

Sonnich wrote:
And while I am at it:

Format - when I want 35 to be shown as 0035 ?


printf()
Is there a way to look for files. eg c:\here\*.pdf (as Dir in VB)?

Yes but the builtin does not implicitly support recursion or wildcards - you
need to implement them for yourself. Alternatively you can run external
programs and read the results back into PHP.

Sonnich wrote:
I am taking this from VB, but what are int and val in PHP?
Largely redundant since it is dynamically typed. But it does provide ceil(),
floor() and round() along with type casting.

$i = Int(Val(substr($code, 3, 3)) / 100) * 100;


Assuming that you may have decimals within the 3 chars:

$i = (integer)substr($code, 3, 3);

C.


Jun 16 '06 #5

P: n/a

Colin McKinnon wrote:
Sonnich - go get a copy of the PHP manual and read it - its free and even
avilable in .chm format. You can download it from
http://www.php.net/docs.php


got it.
Format - when I want 35 to be shown as 0035 ?

printf()


but when I need it in a string?
$a = $blaaaa . "0035";

Jun 19 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.