1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to convert array/string to integer?

Discussion in 'PHP' started by was2_0, Sep 24, 2006.

  1. #1
    only like this:
    $int = array[0] + (array[1] << 8) + (array[2] << 16) + (array[3] << 24);
    ?

    I can't use type casting because it will make a '1111'(4-bytes array) string into 1111(2-byte int), and it's not what i want.

    If mask is a int variable, mask.bin if a file with only 4-byte, so:
    $mask = file_get_contents('mask.bin');
    will make $mask a string not a int???

    Are PHP string variable a pointer to first char in the array? I come from C++...

    Thanks
     
    was2_0, Sep 24, 2006 IP
  2. Evoleto

    Evoleto Well-Known Member

    Messages:
    253
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    108
    #2
    Well, you can try the following:

    
    $mask = file_get_contents('mask.bin');
    $int = intval($mask);
    
    PHP:
     
    Evoleto, Sep 24, 2006 IP