Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default sorting multi-array

    hello,

    i have got a problem, tehere is an array:

    $x = array(
    array(15,55,array(1,2,3),3,5,array(1,2,5)),
    array(25,55,array(1,2,3),3,5,array(1,2,5)),
    array(5,55,array(1,2,3),3,5,array(1,2,5))
    );

    and I need to sort this arraybz first item of sub-arrays (x[0][0],
    $x[1][0], $x[2][0]). this is the correct result:

    $x = array(
    array(5,55,array(1,2,3),3,5,array(1,2,5)),
    array(15,55,array(1,2,3),3,5,array(1,2,5)),
    array(25,55,array(1,2,3),3,5,array(1,2,5))
    );

    some idea how sort this multidimensional array? thank you for your
    reply.

    jiøí nìmec, ICQ: 114651500
    [url]www.menea.cz[/url] - www stránky a aplikace

    JiøîÆèî eË Guest

  2. Similar Questions and Discussions

    1. Sorting array vs sorting paginated array
      ....pulling in a long list of photos in a gallery, and I have a sort function working within the pages of data fine. I need to bring it back out of...
    2. Converting an XML Array to a multi-level array
      I have an array assigned to a data grid such as: private var myIngredients:Array = new Array( <item ln1="Plain" sn="plain" ln2="(3 cups)...
    3. Array Sorting
      Hey everyone, I figured someone out there must have come across the need for this before, so rather than continue banging my head against the...
    4. Sorting a Multidimensional Array
      I have an array like this: $events = array( array( '2003-07-01', 'Event Title 1', '1' //ID Number (not unique) ), array( '2003-07-02',
    5. Sorting multi-page datagrid
      I have a datagrid with many pages. I need to sort the data in a specific page of the grid. The default behavior sorts the whole dataview, causing a...
  3. #2

    Default Re: [PHP] sorting multi-array

    [url]www.php.net/usort[/url] - slight modification of the example (hint: add [0] to
    $a and $b).

    Jiøí Nìmec wrote:
    > hello,
    >
    > i have got a problem, tehere is an array:
    >
    > $x = array(
    > array(15,55,array(1,2,3),3,5,array(1,2,5)),
    > array(25,55,array(1,2,3),3,5,array(1,2,5)),
    > array(5,55,array(1,2,3),3,5,array(1,2,5))
    > );
    >
    > and I need to sort this arraybz first item of sub-arrays (x[0][0],
    > $x[1][0], $x[2][0]). this is the correct result:
    >
    > $x = array(
    > array(5,55,array(1,2,3),3,5,array(1,2,5)),
    > array(15,55,array(1,2,3),3,5,array(1,2,5)),
    > array(25,55,array(1,2,3),3,5,array(1,2,5))
    > );
    >
    > some idea how sort this multidimensional array? thank you for your
    > reply.
    >
    > jiøí nìmec, ICQ: 114651500
    > [url]www.menea.cz[/url] - www stránky a aplikace
    >
    >
    Marek Kilimajer Guest

  4. #3

    Default Re: sorting multi-array

    hi,
    try usort();
    ciao SVEN

    JiøîÆèî eË wrote:
    > hello,
    >
    > i have got a problem, tehere is an array:
    >
    > $x = array(
    > array(15,55,array(1,2,3),3,5,array(1,2,5)),
    > array(25,55,array(1,2,3),3,5,array(1,2,5)),
    > array(5,55,array(1,2,3),3,5,array(1,2,5))
    > );
    >
    > and I need to sort this arraybz first item of sub-arrays (x[0][0],
    > $x[1][0], $x[2][0]). this is the correct result:
    >
    > $x = array(
    > array(5,55,array(1,2,3),3,5,array(1,2,5)),
    > array(15,55,array(1,2,3),3,5,array(1,2,5)),
    > array(25,55,array(1,2,3),3,5,array(1,2,5))
    > );
    >
    > some idea how sort this multidimensional array? thank you for your
    > reply.
    >
    > jiøí nìmec, ICQ: 114651500
    > [url]www.menea.cz[/url] - www stránky a aplikace

    Sven Guest

  5. #4

    Default Re: [PHP] command line or http browser?

    * Thus wrote ermelir (ermelir@ifrance.com):
    > Hi list,
    >
    > I search to detect if a script is call from command line or if the call from
    > a client http browser.
    > for doing that, I test if:
    > php_sapi_name()=='cli'
    > which returns TRUE if script calls from command line; this work fine with
    > PHP 4.2, but with PHP 5 php_sapi_name() returns cgi-fcgi
    > so, I would know if with others php version there is others returns values?
    > and if there is another way to detect if script is call from command line?
    > thanks in advance for yours answers
    This is a good point. I'm not aware of any other names, although I
    have to admit i wan't aware of the sapi_name function either.. :)

    There aught to be a better method of detecting whether you are in
    cli mode or module mode. If this is the only way to determain it I
    would make a suggestion to the php developers to have a way to
    detect what mode your in. Detecting by a string value is very poor
    method of doing it.

    Ok, now after reading the docs, I see why its a string.... Some one
    came up with a list of names, I have no clue where he got it his
    reference tells me nothing.

    - aolserver
    - activescript
    - apache
    - cgi-fcgi
    - cgi
    - isapi
    - nsapi
    - phttpd
    - roxen
    - java_servlet
    - thttpd
    - pi3web
    - apache2filter
    - caudium
    - apache2handler
    - tux
    - webjames
    - cli
    - embed
    - milter


    Curt
    --
    "I used to think I was indecisive, but now I'm not so sure."
    Curt Zirzow Guest

  6. #5

    Default Re: [PHP] command line or http browser?

    thanks for your answer and sorry for my poor english ;)
    in the list of returns values, there somes I can't determine if command line
    or server values
    * isapi
    * nsapi
    * embed
    * milter
    * activescript
    * java_servlet
    do you know?
    thanks for your help


    ----- Original Message -----
    From: "Curt Zirzow" <curt@zirzow.dyndns.org>
    To: <php-general@lists.php.net>
    Sent: Thursday, July 24, 2003 6:22 PM
    Subject: Re: [PHP] command line or http browser?

    > * Thus wrote ermelir (ermelir@ifrance.com):
    > > Hi list,
    > >
    > > I search to detect if a script is call from command line or if the call
    from
    > > a client http browser.
    > > for doing that, I test if:
    > > php_sapi_name()=='cli'
    > > which returns TRUE if script calls from command line; this work fine
    with
    > > PHP 4.2, but with PHP 5 php_sapi_name() returns cgi-fcgi
    > > so, I would know if with others php version there is others returns
    values?
    > > and if there is another way to detect if script is call from command
    line?
    > > thanks in advance for yours answers
    >
    > This is a good point. I'm not aware of any other names, although I
    > have to admit i wan't aware of the sapi_name function either.. :)
    >
    > There aught to be a better method of detecting whether you are in
    > cli mode or module mode. If this is the only way to determain it I
    > would make a suggestion to the php developers to have a way to
    > detect what mode your in. Detecting by a string value is very poor
    > method of doing it.
    >
    > Ok, now after reading the docs, I see why its a string.... Some one
    > came up with a list of names, I have no clue where he got it his
    > reference tells me nothing.
    >
    > - aolserver
    > - activescript
    > - apache
    > - cgi-fcgi
    > - cgi
    > - isapi
    > - nsapi
    > - phttpd
    > - roxen
    > - java_servlet
    > - thttpd
    > - pi3web
    > - apache2filter
    > - caudium
    > - apache2handler
    > - tux
    > - webjames
    > - cli
    > - embed
    > - milter
    >
    >
    > Curt
    > --
    > "I used to think I was indecisive, but now I'm not so sure."
    >
    > --
    > PHP General Mailing List (http://www.php.net/)
    > To unsubscribe, visit: http://www.php.net/unsub.php
    >
    > __________________________________________________ ___________________
    > Envie de discuter en "live" avec vos amis ? Télécharger MSN Messenger
    > http://www.ifrance.com/_reloc/m la 1ère messagerie instantanée de France
    __________________________________________________ ___________________
    Envie de discuter en "live" avec vos amis ? Télécharger MSN Messenger
    http://www.ifrance.com/_reloc/m la 1ère messagerie instantanée de France

    Ermelir Guest

  7. #6

    Default Re: [PHP] command line or http browser?

    * Thus wrote ermelir (ermelir@ifrance.com):
    > thanks for your answer and sorry for my poor english ;)
    > in the list of returns values, there somes I can't determine if command line
    > or server values
    > * isapi
    IIS sapi
    > * nsapi
    Netscape sapi
    > * embed
    > * milter
    > * activescript
    > * java_servlet
    I believe these are all server related not sure though.
    > do you know?
    > thanks for your help
    >
    You're welcome.
    Curt
    --
    "I used to think I was indecisive, but now I'm not so sure."
    Curt Zirzow Guest

  8. #7

    Default Re: [PHP] command line or http browser?

    My uneducated guess is you are running cgi version of php binary, which
    is different from cli version.

    ermelir wrote:
    > Hi list,
    >
    > I search to detect if a script is call from command line or if the callfrom
    > a client http browser.
    > for doing that, I test if:
    > php_sapi_name()=='cli'
    > which returns TRUE if script calls from command line; this work fine with
    > PHP 4.2, but with PHP 5 php_sapi_name() returns cgi-fcgi
    > so, I would know if with others php version there is others returns values?
    > and if there is another way to detect if script is call from command line?
    > thanks in advance for yours answers
    > best regards
    >
    >
    >
    > __________________________________________________ ___________________
    > Envie de discuter en "live" avec vos amis ? Télécharger MSN Messenger
    > [url]http://www.ifrance.com/_reloc/m[/url] la 1ère messagerie instantanée de France
    >
    >
    Marek Kilimajer Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139