asteriskman Posted May 12, 2009 Share Posted May 12, 2009 Hello all. This is my first post here and I appreciate any help you all can provide to me. I have a multiline file as shown below. If anyone is wondering it is the sip.conf file from an asterisk server. From each entry I would please only the username and caller id field into a standard html table to provide a directory listing. Here is the issue. I need to first sort every entry by the context field and then by the caller id field. I do not need to display the context field. By using the parse_ini_file function I am able to place this data in an array but cannot sort it the exact way I want. I sure hope someone has a suggestion. Thank you for your time! ;John Smith [201] type=friend context=a username=201 secret=pass20 callerid=John Smith<4072301234> host=dynamic nat=yes qualify=5000 canreinvite=no dtmfmode=rfc2833 mailbox=201@abc-vm disallow=all allow=g729 ;Andy Jones [202] type=friend context=a username=202 secret=pass202 callerid=Andy Jones<4072301235> host=dynamic nat=yes qualify=5000 canreinvite=no dtmfmode=rfc2833 mailbox=202@abc-vm disallow=all allow=g729 ;Mr X [203] type=friend context=b username=203 secret=pass202 callerid=Mr X<4072301235> host=dynamic nat=yes qualify=5000 canreinvite=no dtmfmode=rfc2833 mailbox=202@abc-vm disallow=all allow=g729 Quote Link to comment https://forums.phpfreaks.com/topic/157817-sorting-a-multi-dimensional-array/ Share on other sites More sharing options...
Maq Posted May 12, 2009 Share Posted May 12, 2009 Can you just do a print_r($array) on your array and post it that way, it's much easier to read Quote Link to comment https://forums.phpfreaks.com/topic/157817-sorting-a-multi-dimensional-array/#findComment-832351 Share on other sites More sharing options...
asteriskman Posted May 12, 2009 Author Share Posted May 12, 2009 Thank you for your quick response! Ive been beating my head against the wall with this for days, lol. Below is the output from the array. Also if it helps the context actually stands for an office. So I am trying to sort by office and then by the persons name to provide a neatly organized directory listing. Array ( [201] => Array ( [type] => friend [context] => a [username] => 201 [secret] => pass20 [callerid] => John Smith<4072301234> [host] => dynamic [nat] => 1 [qualify] => 5000 [canreinvite] => [dtmfmode] => rfc2833 [mailbox] => 201@abc-vm [disallow] => all [allow] => g729 ) [202] => Array ( [type] => friend [context] => a [username] => 202 [secret] => pass202 [callerid] => Andy Jones<4072301235> [host] => dynamic [nat] => 1 [qualify] => 5000 [canreinvite] => [dtmfmode] => rfc2833 [mailbox] => 202@abc-vm [disallow] => all [allow] => g729 ) [203] => Array ( [type] => friend [context] => b [username] => 203 [secret] => pass202 [callerid] => Mr X<4072301235> [host] => dynamic [nat] => 1 [qualify] => 5000 [canreinvite] => [dtmfmode] => rfc2833 [mailbox] => 202@abc-vm [disallow] => all [allow] => g729 ) ) Quote Link to comment https://forums.phpfreaks.com/topic/157817-sorting-a-multi-dimensional-array/#findComment-832414 Share on other sites More sharing options...
allworknoplay Posted May 12, 2009 Share Posted May 12, 2009 Thank you for your quick response! Ive been beating my head against the wall with this for days, lol. Below is the output from the array. Also if it helps the context actually stands for an office. So I am trying to sort by office and then by the persons name to provide a neatly organized directory listing. Array ( [201] => Array ( [type] => friend [context] => a [username] => 201 [secret] => pass20 [callerid] => John Smith<4072301234> [host] => dynamic [nat] => 1 [qualify] => 5000 [canreinvite] => [dtmfmode] => rfc2833 [mailbox] => 201@abc-vm [disallow] => all [allow] => g729 ) [202] => Array ( [type] => friend [context] => a [username] => 202 [secret] => pass202 [callerid] => Andy Jones<4072301235> [host] => dynamic [nat] => 1 [qualify] => 5000 [canreinvite] => [dtmfmode] => rfc2833 [mailbox] => 202@abc-vm [disallow] => all [allow] => g729 ) [203] => Array ( [type] => friend [context] => b [username] => 203 [secret] => pass202 [callerid] => Mr X<4072301235> [host] => dynamic [nat] => 1 [qualify] => 5000 [canreinvite] => [dtmfmode] => rfc2833 [mailbox] => 202@abc-vm [disallow] => all [allow] => g729 ) ) LOL!!! Yes...that is sure much EASIER to read... LOL!!! Quote Link to comment https://forums.phpfreaks.com/topic/157817-sorting-a-multi-dimensional-array/#findComment-832508 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.