translation from VB (int and val)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sonnich

    translation from VB (int and val)

    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.

  • Sonnich

    #2
    Re: translation from VB (int and val)

    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:[color=blue]
    > 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.[/color]

    Comment

    • AlexVN

      #3
      Re: translation from VB (int and val)

      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
      Welcome to COCOL88 link situs VIP dengan tingkat kegacoran 98% dan provider game terbaik di 2026


      Sonnich wrote:[color=blue]
      > 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:[color=green]
      > > 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.[/color][/color]

      Comment

      • Colin McKinnon

        #4
        Re: translation from VB (int and val)

        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
        PHP is a popular general-purpose scripting language that powers everything from your blog to the most popular websites in the world.


        Sonnich wrote:
        [color=blue]
        > And while I am at it:
        >
        > Format - when I want 35 to be shown as 0035 ?
        >[/color]

        printf()
        [color=blue]
        > Is there a way to look for files. eg c:\here\*.pdf (as Dir in VB)?
        >[/color]
        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.
        [color=blue]
        >
        > Sonnich wrote:[color=green]
        >> I am taking this from VB, but what are int and val in PHP?[/color][/color]

        Largely redundant since it is dynamically typed. But it does provide ceil(),
        floor() and round() along with type casting.
        [color=blue][color=green]
        >>
        >> $i = Int(Val(substr( $code, 3, 3)) / 100) * 100;
        >>[/color][/color]

        Assuming that you may have decimals within the 3 chars:

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

        C.

        Comment

        • AlexVN

          #5
          Re: translation from VB (int and val)

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

          Sincerely,
          Alexander
          Welcome to COCOL88 link situs VIP dengan tingkat kegacoran 98% dan provider game terbaik di 2026


          Colin McKinnon wrote:[color=blue]
          > 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:
          >[color=green]
          > > And while I am at it:
          > >
          > > Format - when I want 35 to be shown as 0035 ?
          > >[/color]
          >
          > printf()
          >[color=green]
          > > Is there a way to look for files. eg c:\here\*.pdf (as Dir in VB)?
          > >[/color]
          > 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.
          >[color=green]
          > >
          > > Sonnich wrote:[color=darkred]
          > >> I am taking this from VB, but what are int and val in PHP?[/color][/color]
          >
          > Largely redundant since it is dynamically typed. But it does provide ceil(),
          > floor() and round() along with type casting.
          >[color=green][color=darkred]
          > >>
          > >> $i = Int(Val(substr( $code, 3, 3)) / 100) * 100;
          > >>[/color][/color]
          >
          > Assuming that you may have decimals within the 3 chars:
          >
          > $i = (integer)substr ($code, 3, 3);
          >
          > C.[/color]

          Comment

          • Sonnich

            #6
            Re: translation from VB (int and val)


            Colin McKinnon wrote:[color=blue]
            > 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[/color]

            got it.
            [color=blue][color=green]
            > > Format - when I want 35 to be shown as 0035 ?[/color]
            > printf()[/color]

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

            Comment

            Working...