Stack Exchange
Convert septet to octet in php
I need to convert septets to octest like this c example:
private void septetToOctet()
{
    int len = 1;
    int j = 0;
    int septetcount = septet.Count;

    while (j < septet.Count - 1)
    {
        string tmp = septet[j]; // storing jth value
        string tmp1 = septet[j + 1]; //storing j+1 th value
        string mid = SWAP(tmp1);
        tmp1 = mid;
        tmp1 = tmp1.Substring(0, len);
        string add = SWAP(tmp1);
        tmp = add + tmp;// +"-";
        tmp = tmp.Substring(0, 8);
        //txtoctet.Text += tmp + " || ";
        octet.Add(tmp);
        len++;
        if (len == 8)
        {
            len = 1;
            j = j + 1;
        }
        j = j + 1;
    }
}

..only problem is - i need to do it in php. Does anybody have an code example for this ?

Hi, welcome to Stack Overflow. This is a Q&A site where people help each other to solve particular problems in their code, but it's not a free code writing service. Please have a go at translating the code to PHP yourself, and if there is a particular part you get stuck on, post a question with a clear example of what you have and what you need.

Most of the code can be translated to PHP with little changes. For instance, the first two assignments would be just $len = 1 and $j = 0. There is no strong static typing in PHP. 
Since numbers and strings are scalars in PHP, you cannot call methods on them, so you cannot do tmp1.substring but would have to do substr($tmp1, …).
septet and octet would be arrays in PHP. Again, there is no methods on arrays in PHP. To add to an array, you simply do $octet[] = $tmp. To count the elements you do count($septet).
There is no SWAP in PHP, but you can derive the rather trivial function from Is there a built in swap function in C?
These hints should get you closer to a working implementation.
