Search Results

Search found 20582 results on 824 pages for 'double array'.

Page 1/824 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • PHP Associative array sort

    - by Mithun
    I have an array like one below. Currently it is sorted alphabetically by the OwnerNickName field. Now i want to brig the array entry with OwnerNickName 'My House' as the first entry of the array and rest sorted alphabetically by OwnerNickName. Any idea? Array ( [0318B69D-5DEB-11DF-9D7E-0026B9481364] => Array ( [OwnerNickName] => andy [Rooms] => Array ( [0] => Array ( [Label] => Living Room [RoomKey] => FC795A73-695E-11DF-9D7E-0026B9481364 ) ) ) [286C29DE-A9BE-102D-9C16-00163EEDFCFC] => Array ( [OwnerNickName] => anton [Rooms] => Array ( [0] => Array ( [Label] => KidsRoom [RoomKey] => E79D7991-64DC-11DF-9D7E-0026B9481364 ) [1] => Array ( [Label] => Basement [RoomKey] => CC12C0C4-68AA-11DF-9D7E-0026B9481364 ) [2] => Array ( [Label] => Family Room [RoomKey] => 67A280D4-64D9-11DF-9D7E-0026B9481364 ) ) ) [8BE18F84-AC22-102D-9C16-00163EEDFCFC] => Array ( [OwnerNickName] => mike [Rooms] => Array ( [0] => Array ( [Label] => Family Room [RoomKey] => 1C6AFB39-6835-11DF-9D7E-0026B9481364 ) ) ) [29B455DE-A9BC-102D-9C16-00163EEDFCFC] => Array ( [OwnerNickName] => My House [Rooms] => Array ( [0] => Array ( [Label] => Basement [RoomKey] => 61ECFAB2-6376-11DF-9D7E-0026B9481364 ) [1] => Array ( [Label] => Rec Room [RoomKey] => 52B8B781-6376-11DF-9D7E-0026B9481364 ) [2] => Array ( [Label] => Deck [RoomKey] => FFEB4102-64DE-11DF-9D7E-0026B9481364 ) [3] => Array ( [Label] => My Room2 [RoomKey] => 112473E4-64DF-11DF-9D7E-0026B9481364 ) [4] => Array ( [Label] => Bar Room [RoomKey] => F82C47A8-64DE-11DF-9D7E-0026B9481364 ) ) ) )

    Read the article

  • Searching for a key in a multi dimensional array and adding it to another array [migrated]

    - by Moha
    Let's say I have two multi dimensional arrays: array1 ( stuff1 = array ( data = 'abc' ) stuff2 = array ( something = '123' data = 'def' ) stuff3 = array ( stuff4 = array ( data = 'ghi' ) ) ) array2 ( stuff1 = array ( ) stuff3 = array ( anything = '456' ) ) What I want is to search the key 'data' in array1 and then insert the key and value to array2 regardless of the depth. So wherever key 'data' exists in array1 it gets added to array2 with the exact depth (and key names) as in array1 AND without modifying any other keys. How can I do this recursively?

    Read the article

  • Checking if an array contains all elements of another array

    - by mozcelikors
    I'm designing an electrical engineering application. However, i'm stuck on this: I have the following array <?php // Static Array $GroupOfEight = array ( array(0,1,3,2,4,5,7,6), array(4,5,6,7,16,12,13,14), array(12,13,15,14,8,9,11,10), array(2,6,14,10,3,7,15,11), array(1,3,5,7,13,15,9,11), array(0,4,12,8,1,5,13,9), array(0,1,3,2,8,9,11,10) ); ?> And I have another array, but this one is one dimensional. <?php $myStack = array(0,1,3,2,4,5,7,6); //Dynamic, gets value by POST method. ?> What I want to do is to check if $myStack is equal to any sub array of $GroupOfEight array. ( Number ordering is not important. The script should just check if every elements contained. It's not important if their order is same or not. ) Here is what I've done to solve the issue so far: <?php //Check if stackArray contains 8group for($i=0; $i<count($GroupOfEight);$i++) for($j=0; $j<count($GroupOfEight[$i]); $j++){ //$containsSearch = count(array_intersect($search_this,$all)) == count($search_this); $containsSearch = count(array_intersect($stackArray,$GroupOfEight[$j])) == count($stackArray); echo $containsSearch; } ?> Please help me correct my code or introduce me the solution of this issue, Thanks.

    Read the article

  • Converting a flat array to a nested array

    - by matte
    Hi, I am trying to convert a flat array to a nested array depending on the 'level' data of each array item. 'level' data shows us if current array item is a child, a parent or a sibling. Here is the flat array: $sequentialArray = array( array('title'=>'Page 1', 'level'=>0), array('title'=>'Page 2', 'level'=>0), array('title'=>'Page 3', 'level'=>1), array('title'=>'Page 4', 'level'=>1), array('title'=>'Page 5', 'level'=>2), array('title'=>'Page 6', 'level'=>0), array('title'=>'Page 7', 'level'=>1), array('title'=>'Page 8', 'level'=>0) ); And here is the expected result: $nestedArray = array( array('title'=>'Page 1', 'children'=>array()), array('title'=>'Page 2', 'children'=>array( array('title'=>'Page 3', 'children'=>array()), array('title'=>'Page 4', 'children'=>array( array('title'=>'Page 5', 'children'=>array()) )), )), array('title'=>'Page 6', 'children'=>array( array('title'=>'Page 7', 'children'=>array()) )), array('title'=>'Page 8', 'children'=>array()), ); I tried using references with array indexes but that didn't work. Any ideas?

    Read the article

  • C# (4): double minus double giving precision problems

    - by thermal7
    I have come across a precision issue with double in .NET I thought this only applied to floats but now I see that double is a float. double test = 278.97 - 90.46; Debug.WriteLine(test) //188.51000000000005 //correct answer is 188.51 What is the correct way to handle this? Round? Lop off the unneeded decimal places?

    Read the article

  • php if array key exists inside multidimentional array

    - by Richard
    how can i check if logo exists in this array called $attachements print_r is below: Array ( [logo] = /home/richar2/public_html/ioagh/images/stories/jreviews/20100510115659_1_img.gif ) when theres no logo, the array print_r's Array ( ) i tried: if (isset($attachments['logo']) ) {..} but the conditional code runs when there is no logo

    Read the article

  • C++ Static array vs. Dynamic array?

    - by user69514
    What is the difference between a static array and a dynamic array in C++? I have to do an assignment for my class and it says not to use static arrays, only dynamic arrays. I've looked in the book and online, but I don't seem to understand. I thought static was created at compile time and dynamic at runtime, but I might be mistaken this with memory allocation. Can you explain to me the difference between static array and dynamic array in C++? Thnaks.

    Read the article

  • Using delegates in C# (Part 2)

    - by rajbk
    Part 1 of this post can be read here. We are now about to see the different syntaxes for invoking a delegate and some c# syntactic sugar which allows you to code faster. We have the following console application. 1: public delegate double Operation(double x, double y); 2:  3: public class Program 4: { 5: [STAThread] 6: static void Main(string[] args) 7: { 8: Operation op1 = new Operation(Division); 9: double result = op1.Invoke(10, 5); 10: 11: Console.WriteLine(result); 12: Console.ReadLine(); 13: } 14: 15: static double Division(double x, double y) { 16: return x / y; 17: } 18: } Line 1 defines a delegate type called Operation with input parameters (double x, double y) and a return type of double. On Line 8, we create an instance of this delegate and set the target to be a static method called Division (Line 15) On Line 9, we invoke the delegate (one entry in the invocation list). The program outputs 5 when run. The language provides shortcuts for creating a delegate and invoking it (see line 9 and 11). Line 9 is a syntactical shortcut for creating an instance of the Delegate. The C# compiler will infer on its own what the delegate type is and produces intermediate language that creates a new instance of that delegate. Line 11 uses a a syntactical shortcut for invoking the delegate by removing the Invoke method. The compiler sees the line and generates intermediate language which invokes the delegate. When this code is compiled, the generated IL will look exactly like the IL of the compiled code above. 1: public delegate double Operation(double x, double y); 2:  3: public class Program 4: { 5: [STAThread] 6: static void Main(string[] args) 7: { 8: //shortcut constructor syntax 9: Operation op1 = Division; 10: //shortcut invoke syntax 11: double result = op1(10, 2); 12: 13: Console.WriteLine(result); 14: Console.ReadLine(); 15: } 16: 17: static double Division(double x, double y) { 18: return x / y; 19: } 20: } C# 2.0 introduced Anonymous Methods. Anonymous methods avoid the need to create a separate method that contains the same signature as the delegate type. Instead you write the method body in-line. There is an interesting fact about Anonymous methods and closures which won’t be covered here. Use your favorite search engine ;-)We rewrite our code to use anonymous methods (see line 9): 1: public delegate double Operation(double x, double y); 2:  3: public class Program 4: { 5: [STAThread] 6: static void Main(string[] args) 7: { 8: //Anonymous method 9: Operation op1 = delegate(double x, double y) { 10: return x / y; 11: }; 12: double result = op1(10, 2); 13: 14: Console.WriteLine(result); 15: Console.ReadLine(); 16: } 17: 18: static double Division(double x, double y) { 19: return x / y; 20: } 21: } We could rewrite our delegate to be of a generic type like so (see line 2 and line 9). You will see why soon. 1: //Generic delegate 2: public delegate T Operation<T>(T x, T y); 3:  4: public class Program 5: { 6: [STAThread] 7: static void Main(string[] args) 8: { 9: Operation<double> op1 = delegate(double x, double y) { 10: return x / y; 11: }; 12: double result = op1(10, 2); 13: 14: Console.WriteLine(result); 15: Console.ReadLine(); 16: } 17: 18: static double Division(double x, double y) { 19: return x / y; 20: } 21: } The .NET 3.5 framework introduced a whole set of predefined delegates for us including public delegate TResult Func<T1, T2, TResult>(T1 arg1, T2 arg2); Our code can be modified to use this delegate instead of the one we declared. Our delegate declaration has been removed and line 7 has been changed to use the Func delegate type. 1: public class Program 2: { 3: [STAThread] 4: static void Main(string[] args) 5: { 6: //Func is a delegate defined in the .NET 3.5 framework 7: Func<double, double, double> op1 = delegate (double x, double y) { 8: return x / y; 9: }; 10: double result = op1(10, 2); 11: 12: Console.WriteLine(result); 13: Console.ReadLine(); 14: } 15: 16: static double Division(double x, double y) { 17: return x / y; 18: } 19: } .NET 3.5 also introduced lambda expressions. A lambda expression is an anonymous function that can contain expressions and statements, and can be used to create delegates or expression tree types. We change our code to use lambda expressions. 1: public class Program 2: { 3: [STAThread] 4: static void Main(string[] args) 5: { 6: //lambda expression 7: Func<double, double, double> op1 = (x, y) => x / y; 8: double result = op1(10, 2); 9: 10: Console.WriteLine(result); 11: Console.ReadLine(); 12: } 13: 14: static double Division(double x, double y) { 15: return x / y; 16: } 17: } C# 3.0 introduced the keyword var (implicitly typed local variable) where the type of the variable is inferred based on the type of the associated initializer expression. We can rewrite our code to use var as shown below (line 7).  The implicitly typed local variable op1 is inferred to be a delegate of type Func<double, double, double> at compile time. 1: public class Program 2: { 3: [STAThread] 4: static void Main(string[] args) 5: { 6: //implicitly typed local variable 7: var op1 = (x, y) => x / y; 8: double result = op1(10, 2); 9: 10: Console.WriteLine(result); 11: Console.ReadLine(); 12: } 13: 14: static double Division(double x, double y) { 15: return x / y; 16: } 17: } You have seen how we can write code in fewer lines by using a combination of the Func delegate type, implicitly typed local variables and lambda expressions.

    Read the article

  • Sorting a Multidimensional array...

    - by sologhost
    I need to sort an array that can look like this: $array[4][0] = array('id' => 1, 'value' => 2); $array[3][2] = array('id' => 0, 'value' => 3); $array[4][1] = array('id' => 1, 'value' => 0); $array[1][3] = array('id' => 2, 'value' => 1); $array[1][1] = array('id' => 3, 'value' => 0); $array[3][0] = array('id' => 2, 'value' => 1); $array[3][1] = array('id' => 1, 'value' => 0); $array[1][2] = array('id' => 3, 'value' => 2); $array[1][0] = array('id' => 2, 'value' => 1); $array[2][1] = array('id' => 0, 'value' => 2); $array[2][4] = array('id' => 3, 'value' => 1); But needs to be sorted and returned as this: $array[1][0] = array('id' => 2, 'value' => 1); $array[1][1] = array('id' => 3, 'value' => 0); $array[1][2] = array('id' => 3, 'value' => 2); $array[1][3] = array('id' => 2, 'value' => 1); $array[2][1] = array('id' => 0, 'value' => 2); $array[2][4] = array('id' => 3, 'value' => 1); $array[3][0] = array('id' => 2, 'value' => 1); $array[3][1] = array('id' => 1, 'value' => 0); $array[3][2] = array('id' => 0, 'value' => 3); $array[4][0] = array('id' => 1, 'value' => 2); $array[4][1] = array('id' => 1, 'value' => 0); Can anyone help me? It needs to sort both indexes of the array from lowest to highest index value. Sounds simple enough, but I'm having the hardest time trying to figure this out, while still keeping the values intact. Please help someone...

    Read the article

  • Read array dump output and generates the correspondent XML file

    - by Christian
    Hi, The text below is the dump of a multidimensional array, dumped by the var_dump() PHP function. I need a Java function that reads a file with a content like this (attached) and returns it in XML. For a reference, in site http://pear.php.net/package/Var_Dump/ you can find the code (in PHP) that generates dumps in XML, so all neeeded logic is there (I think). I will be waiting for your feedback. Regards, Christian array(1) { ["Processo"]= array(60) { ["Sistema"]= string(6) "E-PROC" ["UF"]= string(2) "RS" ["DataConsulta"]= string(19) "11/05/2010 17:59:17" ["Processo"]= string(20) "50000135320104047100" ["NumRegistJudici"]= string(20) "50000135320104047100" ["IdProcesso"]= string(30) "711262958983115560390000000001" ["SeqProcesso"]= string(1) "1" ["Autuado"]= string(19) "08/01/2010 12:04:47" ["StatusProcesso"]= string(1) "M" ["ComSituacaoProcesso"]= string(2) "00" ["Situacao"]= string(9) "MOVIMENTO" ["IdClasseJudicial"]= string(10) "0000000112" ["DesClasse"]= string(18) "INQUÉRITO POLICIAL" ["CodClasse"]= string(6) "000120" ["SigClasse"]= string(3) "INQ" ["DesTipoInquerito"]= string(0) "" ["CodCompetencia"]= string(2) "21" ["IdLocalidadeJudicial"]= string(4) "7150" ["ClasseSigAutor"]= string(5) "AUTOR" ["ClasseDesAutor"]= string(5) "AUTOR" ["ClasseSigReu"]= string(7) "INDICDO" ["ClasseDesReu"]= string(9) "INDICIADO" ["ClasseCodReu"]= string(2) "64" ["TipoAcao"]= string(8) "Criminal" ["TipoProcessoJudicial"]= string(1) "2" ["CodAssuntoPrincipal"]= string(6) "051801" ["CodLocalidadeJudicial"]= string(2) "00" ["IdAssuntoPrincipal"]= string(4) "1504" ["IdLocalizadorOrgaoPrincipal"]= string(30) "711264420823128430420000000001" ["ChaveConsulta"]= string(12) "513009403710" ["NumAdministrativo"]= NULL ["Magistrado"]= string(28) "RICARDO HUMBERTO SILVA BORNE" ["IdOrgaoJuizo"]= string(9) "710000085" ["IdOrgaoJuizoOriginario"]= string(9) "710000085" ["DesOrgaoJuizo"]= string(45) "JUÍZO FED. DA 02A VF CRIMINAL DE PORTO ALEGRE" ["SigOrgaoJuizo"]= string(10) "RSPOACR02F" ["CodOrgaoJuizo"]= string(9) "RS0000085" ["IdOrgaoSecretaria"]= string(9) "710000084" ["DesOrgaoSecretaria"]= string(31) "02a VF CRIMINAL DE PORTO ALEGRE" ["SigOrgaoSecretaria"]= string(9) "RSPOACR02" ["CodOrgaoSecretaria"]= string(9) "RS0000084" ["IdSigilo"]= string(1) "0" ["IdUsuario"]= string(30) "711262951173995330420000000001" ["DesSigilo"]= string(10) "Sem Sigilo" ["Localizador"]= string(25) "EM TRÂMITE ENTRE PF E MPF" ["TotalCda"]= int(0) ["DesIpl"]= string(8) "012/2010" ["Assunto"]= array(1) { [0]= array(4) { ["IdAssuntoJudicial"]= string(4) "1504" ["SeqAssunto"]= string(1) "1" ["CodAssunto"]= string(6) "051801" ["DesAssunto"]= string(84) "Moeda Falsa / Assimilados (arts. 289 e parágrafos e 290), Crimes contra a Fé Pública" } } ["ParteAutor"]= array(1) { [0]= array(12) { ["IdPessoa"]= string(30) "771230778800100040000000000508" ["TipoPessoa"]= string(3) "ENT" ["Nome"]= string(15) "POLÍCIA FEDERAL" ["Identificacao"]= string(14) "79621439000191" ["SinPartePrincipal"]= string(1) "S" ["IdProcessoParte"]= string(30) "711262958983115560390000000002" ["IdProcessoParteAtributo"]= NULL ["IdRepresentacao"]= NULL ["TipoRepresentacao"]= NULL ["AtributosProcessoParte"]= NULL ["Relacao"]= NULL ["Procurador"]= array(6) { [0]= array(4) { ["Nome"]= string(25) "SOLON RAMOS CARDOSO FILHO" ["Sigla"]= string(13) "cor-sr-dpf-rs" ["IdUsuarioProcurador"]= string(30) "711262893271855450420000000001" ["TipoUsuario"]= string(3) "CPF" } [1]= array(4) { ["Nome"]= string(18) "LUCIANA IOP CECHIN" ["Sigla"]= string(11) "luciana.lic" ["IdUsuarioProcurador"]= string(30) "711262946806708880420000000001" ["TipoUsuario"]= string(3) "CPF" } [2]= array(4) { ["Nome"]= string(31) "ALEXANDRE DA SILVEIRA ISBARROLA" ["Sigla"]= string(15) "drcor-sr-dpf-rs" ["IdUsuarioProcurador"]= string(30) "711262949451860560420000000001" ["TipoUsuario"]= string(3) "CPF" } [3]= array(4) { ["Nome"]= string(24) "JUCÉLIA TERESINHA PISONI" ["Sigla"]= string(11) "jucelia.jtp" ["IdUsuarioProcurador"]= string(30) "711262950492275450420000000001" ["TipoUsuario"]= string(3) "CPF" } [4]= array(4) { ["Nome"]= string(32) "MARCOS ANTONIO SIQUEIRA PICININI" ["Sigla"]= string(13) "picinini.masp" ["IdUsuarioProcurador"]= string(30) "711262951173995330420000000001" ["TipoUsuario"]= string(3) "APF" } [5]= array(4) { ["Nome"]= string(20) "PRISCILLA BURLACENKO" ["Sigla"]= string(12) "priscilla.pb" ["IdUsuarioProcurador"]= string(30) "711262955631630740420000000001" ["TipoUsuario"]= string(3) "DPF" } } } } ["ParteReu"]= array(1) { [0]= array(11) { ["IdPessoa"]= string(30) "711262958983115560390000000001" ["TipoPessoa"]= string(2) "PF" ["Nome"]= string(8) "A APURAR" ["Identificacao"]= NULL ["SinPartePrincipal"]= string(1) "S" ["IdProcessoParte"]= string(30) "711262958983115560390000000001" ["IdProcessoParteAtributo"]= NULL ["IdRepresentacao"]= NULL ["TipoRepresentacao"]= NULL ["AtributosProcessoParte"]= NULL ["Relacao"]= NULL } } ["OutraParte"]= array(1) { [0]= array(10) { ["Nome"]= string(26) "MINISTÉRIO PÚBLICO FEDERAL" ["CodTipoParte"]= string(3) "114" ["DesTipoParte"]= string(3) "MPF" ["SinPolo"]= string(1) "N" ["Identificacao"]= string(13) "3636198000192" ["SinPartePrincipal"]= string(1) "N" ["IdProcessoParte"]= string(30) "711262958983115560390000000003" ["IdPessoa"]= string(30) "771230778800100040000000000217" ["TipoPessoa"]= string(3) "ENT" ["Procurador"]= array(1) { [0]= array(4) { ["Nome"]= string(25) "MARIA VALESCA DE MESQUITA" ["IdUsuarioProcurador"]= string(30) "711265220162198740420000000001" ["TipoUsuario"]= string(1) "P" ["Sigla"]= string(5) "pr528" } } } } ["DadoComplementar"]= array(6) { [0]= array(5) { ["DesDadoComplem"]= string(21) "Antecipação de Tutela" ["ValorDadoComplem"]= string(13) "Não Requerida" ["IdDadoComplementar"]= string(1) "1" ["NumIdProcessoDadoComplem"]= string(30) "711262958983115560390000000003" ["IdDadoComplementarValor"]= string(1) "4" } [1]= array(5) { ["DesDadoComplem"]= string(16) "Justiça Gratuita" ["ValorDadoComplem"]= string(13) "Não Requerida" ["IdDadoComplementar"]= string(1) "4" ["NumIdProcessoDadoComplem"]= string(30) "711262958983115560390000000001" ["IdDadoComplementarValor"]= string(1) "3" } [2]= array(5) { ["DesDadoComplem"]= string(15) "Petição Urgente" ["ValorDadoComplem"]= string(3) "Não" ["IdDadoComplementar"]= string(1) "5" ["NumIdProcessoDadoComplem"]= string(30) "711262958983115560390000000004" ["IdDadoComplementarValor"]= string(1) "2" } [3]= array(5) { ["DesDadoComplem"]= string(22) "Prioridade Atendimento" ["ValorDadoComplem"]= string(3) "Não" ["IdDadoComplementar"]= string(1) "2" ["NumIdProcessoDadoComplem"]= string(30) "711262958983115560390000000006" ["IdDadoComplementarValor"]= string(1) "2" } [4]= array(5) { ["DesDadoComplem"]= string(9) "Réu Preso" ["ValorDadoComplem"]= string(3) "Não" ["IdDadoComplementar"]= string(1) "6" ["NumIdProcessoDadoComplem"]= string(30) "711262958983115560390000000002" ["IdDadoComplementarValor"]= string(1) "2" } [5]= array(5) { ["DesDadoComplem"]= string(24) "Vista Ministério Público" ["ValorDadoComplem"]= string(3) "Sim" ["IdDadoComplementar"]= string(1) "3" ["NumIdProcessoDadoComplem"]= string(30) "711262958983115560390000000005" ["IdDadoComplementarValor"]= string(1) "1" } } ["SemPrazoAbrir"]= bool(true) ["Evento"]= array(8) { [0]= array(18) { ["IdProcessoEvento"]= string(30) "711269271039215440420000000001" ["IdEvento"]= string(3) "228" ["IdTipoPeticaoJudicial"]= string(3) "166" ["SeqEvento"]= string(1) "8" ["DataHora"]= string(19) "22/03/2010 12:19:16" ["SinExibeDesEvento"]= string(1) "S" ["SinUsuarioInterno"]= string(1) "N" ["IdGrupoEvento"]= string(1) "4" ["SinVisualizaDocumentoExterno"]= string(1) "N" ["Complemento"]= string(7) "90 DIAS" ["DesEventoSemComplemento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["CodEvento"]= string(10) "0000000852" ["DesEvento"]= string(37) "PETIÇÃO PROTOCOLADA JUNTADA - 90 DIAS" ["DesAlternativaEvento"]= NULL ["Usuario"]= string(7) "ap18785" ["idUsuario"]= string(30) "711263330517182580420000000001" ["DesPeticao"]= string(25) "DILAÇÃO DE PRAZO DEFERIDA" ["DescricaoCompleta"]= string(75) "PETIÇÃO PROTOCOLADA JUNTADA - 90 DIAS - DILAÇÃO DE PRAZO DEFERIDA - 90 DIAS" } [1]= array(18) { ["IdProcessoEvento"]= string(30) "711269032501923580420000000001" ["IdEvento"]= string(3) "228" ["IdTipoPeticaoJudicial"]= string(3) "166" ["SeqEvento"]= string(1) "7" ["DataHora"]= string(19) "19/03/2010 18:04:59" ["SinExibeDesEvento"]= string(1) "S" ["SinUsuarioInterno"]= string(1) "N" ["IdGrupoEvento"]= string(1) "4" ["SinVisualizaDocumentoExterno"]= string(1) "N" ["Complemento"]= string(7) "90 DIAS" ["DesEventoSemComplemento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["CodEvento"]= string(10) "0000000852" ["DesEvento"]= string(37) "PETIÇÃO PROTOCOLADA JUNTADA - 90 DIAS" ["DesAlternativaEvento"]= NULL ["Usuario"]= string(5) "pr700" ["idUsuario"]= string(30) "711262976146980920420000000002" ["DesPeticao"]= string(25) "DILAÇÃO DE PRAZO DEFERIDA" ["DescricaoCompleta"]= string(75) "PETIÇÃO PROTOCOLADA JUNTADA - 90 DIAS - DILAÇÃO DE PRAZO DEFERIDA - 90 DIAS" } [2]= array(19) { ["IdProcessoEvento"]= string(30) "711268077089625240420000000001" ["IdEvento"]= string(3) "228" ["IdTipoPeticaoJudicial"]= string(3) "165" ["SeqEvento"]= string(1) "6" ["DataHora"]= string(19) "08/03/2010 16:55:48" ["SinExibeDesEvento"]= string(1) "N" ["SinUsuarioInterno"]= string(1) "N" ["IdGrupoEvento"]= string(1) "4" ["SinVisualizaDocumentoExterno"]= string(1) "N" ["Complemento"]= NULL ["DesEventoSemComplemento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["CodEvento"]= string(10) "0000000852" ["DesEvento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["DesAlternativaEvento"]= NULL ["Usuario"]= string(13) "picinini.masp" ["idUsuario"]= string(30) "711262951173995330420000000001" ["Documento"]= array(2) { [0]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711268077089625240420000000001" ["SeqDocumento"]= string(1) "1" ["SigTipoDocumento"]= string(4) "CERT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [1]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711268077089625240420000000002" ["SeqDocumento"]= string(1) "2" ["SigTipoDocumento"]= string(4) "DESP" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } } ["DesPeticao"]= string(26) "PEDIDO DE DILAÇÃO DE PRAZO" ["DescricaoCompleta"]= string(26) "PEDIDO DE DILAÇÃO DE PRAZO" } [3]= array(19) { ["IdProcessoEvento"]= string(30) "711267732906972600420000000001" ["IdEvento"]= string(3) "228" ["IdTipoPeticaoJudicial"]= string(2) "52" ["SeqEvento"]= string(1) "5" ["DataHora"]= string(19) "04/03/2010 17:20:29" ["SinExibeDesEvento"]= string(1) "N" ["SinUsuarioInterno"]= string(1) "N" ["IdGrupoEvento"]= string(1) "4" ["SinVisualizaDocumentoExterno"]= string(1) "N" ["Complemento"]= NULL ["DesEventoSemComplemento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["CodEvento"]= string(10) "0000000852" ["DesEvento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["DesAlternativaEvento"]= NULL ["Usuario"]= string(5) "pr700" ["idUsuario"]= string(30) "711262976146980920420000000002" ["Documento"]= array(1) { [0]= array(6) { ["IdUsuario"]= string(30) "711262976146980920420000000002" ["IdDocumento"]= string(30) "711267732906972600420000000001" ["SeqDocumento"]= string(1) "1" ["SigTipoDocumento"]= string(3) "PET" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } } ["DesPeticao"]= string(7) "PETIÇÃO" ["DescricaoCompleta"]= string(7) "PETIÇÃO" } [4]= array(19) { ["IdProcessoEvento"]= string(30) "711265889365256290420000000001" ["IdEvento"]= string(3) "228" ["IdTipoPeticaoJudicial"]= string(3) "165" ["SeqEvento"]= string(1) "4" ["DataHora"]= string(19) "11/02/2010 09:59:04" ["SinExibeDesEvento"]= string(1) "N" ["SinUsuarioInterno"]= string(1) "N" ["IdGrupoEvento"]= string(1) "4" ["SinVisualizaDocumentoExterno"]= string(1) "N" ["Complemento"]= NULL ["DesEventoSemComplemento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["CodEvento"]= string(10) "0000000852" ["DesEvento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["DesAlternativaEvento"]= NULL ["Usuario"]= string(13) "picinini.masp" ["idUsuario"]= string(30) "711262951173995330420000000001" ["Documento"]= array(2) { [0]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711265222866995860420000000001" ["SeqDocumento"]= string(1) "1" ["SigTipoDocumento"]= string(4) "PORT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [1]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711265222866995860420000000002" ["SeqDocumento"]= string(1) "2" ["SigTipoDocumento"]= string(3) "OUT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } } ["DesPeticao"]= string(26) "PEDIDO DE DILAÇÃO DE PRAZO" ["DescricaoCompleta"]= string(26) "PEDIDO DE DILAÇÃO DE PRAZO" } [5]= array(19) { ["IdProcessoEvento"]= string(30) "711263991150788270420000000001" ["IdEvento"]= string(3) "228" ["IdTipoPeticaoJudicial"]= string(2) "52" ["SeqEvento"]= string(1) "3" ["DataHora"]= string(19) "20/01/2010 10:50:05" ["SinExibeDesEvento"]= string(1) "N" ["SinUsuarioInterno"]= string(1) "N" ["IdGrupoEvento"]= string(1) "4" ["SinVisualizaDocumentoExterno"]= string(1) "N" ["Complemento"]= NULL ["DesEventoSemComplemento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["CodEvento"]= string(10) "0000000852" ["DesEvento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["DesAlternativaEvento"]= NULL ["Usuario"]= string(13) "picinini.masp" ["idUsuario"]= string(30) "711262951173995330420000000001" ["Documento"]= array(4) { [0]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711263991150788270420000000001" ["SeqDocumento"]= string(1) "1" ["SigTipoDocumento"]= string(4) "DECL" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [1]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711263991150788270420000000002" ["SeqDocumento"]= string(1) "2" ["SigTipoDocumento"]= string(4) "DECL" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [2]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711263991150788270420000000003" ["SeqDocumento"]= string(1) "3" ["SigTipoDocumento"]= string(4) "DECL" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [3]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711263991150788270420000000004" ["SeqDocumento"]= string(1) "4" ["SigTipoDocumento"]= string(4) "DECL" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } } ["DesPeticao"]= string(7) "PETIÇÃO" ["DescricaoCompleta"]= string(7) "PETIÇÃO" } [6]= array(19) { ["IdProcessoEvento"]= string(30) "711263955058688620420000000001" ["IdEvento"]= string(3) "228" ["IdTipoPeticaoJudicial"]= string(2) "52" ["SeqEvento"]= string(1) "2" ["DataHora"]= string(19) "20/01/2010 00:40:39" ["SinExibeDesEvento"]= string(1) "N" ["SinUsuarioInterno"]= string(1) "N" ["IdGrupoEvento"]= string(1) "4" ["SinVisualizaDocumentoExterno"]= string(1) "N" ["Complemento"]= NULL ["DesEventoSemComplemento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["CodEvento"]= string(10) "0000000852" ["DesEvento"]= string(27) "PETIÇÃO PROTOCOLADA JUNTADA" ["DesAlternativaEvento"]= NULL ["Usuario"]= string(13) "picinini.masp" ["idUsuario"]= string(30) "711262951173995330420000000001" ["Documento"]= array(6) { [0]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711263229632249660420000000001" ["SeqDocumento"]= string(1) "1" ["SigTipoDocumento"]= string(3) "OUT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [1]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711263229632249660420000000002" ["SeqDocumento"]= string(1) "2" ["SigTipoDocumento"]= string(3) "OUT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [2]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711263229632249660420000000003" ["SeqDocumento"]= string(1) "3" ["SigTipoDocumento"]= string(3) "OUT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [3]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711263229632249660420000000004" ["SeqDocumento"]= string(1) "4" ["SigTipoDocumento"]= string(3) "OUT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [4]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711263229632249660420000000005" ["SeqDocumento"]= string(1) "5" ["SigTipoDocumento"]= string(3) "OUT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [5]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711263229632249660420000000006" ["SeqDocumento"]= string(1) "6" ["SigTipoDocumento"]= string(3) "OUT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } } ["DesPeticao"]= string(7) "PETIÇÃO" ["DescricaoCompleta"]= string(7) "PETIÇÃO" } [7]= array(19) { ["IdProcessoEvento"]= string(30) "711262958983115560390000000001" ["IdEvento"]= string(3) "430" ["IdTipoPeticaoJudicial"]= NULL ["SeqEvento"]= string(1) "1" ["DataHora"]= string(19) "08/01/2010 12:04:47" ["SinExibeDesEvento"]= NULL ["SinUsuarioInterno"]= string(1) "N" ["IdGrupoEvento"]= string(1) "0" ["SinVisualizaDocumentoExterno"]= string(1) "N" ["Complemento"]= NULL ["DesEventoSemComplemento"]= string(56) "Distribuição/Atribuição Ordinária por sorteio eletrônico" ["CodEvento"]= string(6) "030101" ["DesEvento"]= string(56) "Distribuição/Atribuição Ordinária por sorteio eletrônico" ["DesAlternativaEvento"]= NULL ["Usuario"]= string(13) "picinini.masp" ["idUsuario"]= string(30) "711262951173995330420000000001" ["Documento"]= array(4) { [0]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711262956008922510390000000001" ["SeqDocumento"]= string(1) "1" ["SigTipoDocumento"]= string(4) "PORT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [1]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711262956008922510390000000002" ["SeqDocumento"]= string(1) "2" ["SigTipoDocumento"]= string(4) "OFIC" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [2]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711262956008922510390000000003" ["SeqDocumento"]= string(1) "3" ["SigTipoDocumento"]= string(3) "OUT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } [3]= array(6) { ["IdUsuario"]= string(30) "711262951173995330420000000001" ["IdDocumento"]= string(30) "711262956008922510390000000004" ["SeqDocumento"]= string(1) "4" ["SigTipoDocumento"]= string(3) "OUT" ["IdSigilo"]= string(1) "0" ["DesSigilo"]= string(10) "Sem Sigilo" } } ["DesPeticao"]= string(56) "Distribuição/Atribuição Ordinária por sorteio eletrônico" ["DescricaoCompleta"]= string(56) "Distribuição/Atribuição Ordinária por sorteio eletrônico" } } ["ValCausa"]= string(4) "0.00" ["OrgaoJul"]= string(45) "JUÍZO FED. DA 02A VF CRIMINAL DE PORTO ALEGRE" ["CodOrgaoJul"]= string(9) "RS0000085" ["OrgaoColegiado"]= NULL ["CodOrgaoColegiado"]= NULL ["CodOrgaoColegiadoSecretaria"]= NULL } }

    Read the article

  • PHP - "tabulate" array - make levels from elements

    - by Moha
    If I have an array like this: Array ( [0] => field_schools [1] => und [2] => 0 [3] => field_school [4] => und [5] => 0 [6] => value ) How can I make an array like this from it? array ( [field_schools] => array ( [und] => array ( [0] => array ( [field_school] => array ( [und] => array ( [0] => array ( [value] => something ) ) ) ) ) ) ) I want to specify the 'value' myself.

    Read the article

  • Length of array (C) [migrated]

    - by physics
    I have an array of 10 elements. This array stocks some informations but last information is ended by an symbol "END" (which is -1). for exemple: array[0] = 1; array[1] = 1; array[2] = 1; array[3] = 1; array[4] = 1; array[5] = 1; array[6] = END; So in this case the length is 7 instead of 10. Here is my algorithm: for (i = 0; (i < 10) && (array[i] != END); i++) { ; } at the end i contains the length. Is it correct or there is an other methode?

    Read the article

  • Compare two associative arrays and create a new array with the matched arrays, PHP

    - by user194630
    I have this two arrays: $arr1=array( array("id" => 8, "name" => "test1"), array("id" => 4, "name" => "test2"), array("id" => 3, "name" => "test3") ); $arr2=array( array("id" => 3), array("id" => 4) ); How can i "extract" arrays from $arr1, where id have same value in $arr2, into a new array and leave the extracted array also in a new array, without taking into account key orders? The output i am looking for should be: $arr3=array( array("id" => 8, "name" => "test1") ); $arr4=array( array("id" => 4, "name" => "test2"), array("id" => 3, "name" => "test3") ); Thanks

    Read the article

  • Array Unique in two dimentional array in PHP

    - by Kaiser
    Hi I have an array that looks like this : Array ( [0] => Array ( [x] => 01 [y] => 244 ) [1] => Array ( [x] => 02 [y] => 244 ) [2] => Array ( [x] => 03 [y] => 244 ) [3] => Array ( [x] => 04 [y] => 243 ) [4] => Array ( [x] => 05 [y] => 243 ) [5] => Array ( [x] => 05 [y] => 244 ) [6] => Array ( [x] => 06 [y] => 242 ) [7] => Array ( [x] => 06 [y] => 243 ) [8] => Array ( [x] => 07 [y] => 243 ) [9] => Array ( [x] => 08 [y] => 243 ) [10] => Array ( [x] => 09 [y] => 242 ) [11] => Array ( [x] => 10 [y] => 244 ) [12] => Array ( [x] => 12 [y] => 243 ) [13] => Array ( [x] => 13 [y] => 243 ) [14] => Array ( [x] => 13 [y] => 243 ) [15] => Array ( [x] => 15 [y] => 243 ) ) x represent days and y values of a certain variable. I would like to display an array of unique days x ( last element ) and values y pragmatically. for example day 6 I have two y values but I want to display only the last one ( 243 ). Thanks for help

    Read the article

  • Array Unique in two dimensional array in PHP

    - by Kaiser
    Hi I have an array that looks like this : Array ( [0] => Array ( [x] => 01 [y] => 244 ) [1] => Array ( [x] => 02 [y] => 244 ) [2] => Array ( [x] => 03 [y] => 244 ) [3] => Array ( [x] => 04 [y] => 243 ) [4] => Array ( [x] => 05 [y] => 243 ) [5] => Array ( [x] => 05 [y] => 244 ) [6] => Array ( [x] => 06 [y] => 242 ) [7] => Array ( [x] => 06 [y] => 243 ) [8] => Array ( [x] => 07 [y] => 243 ) [9] => Array ( [x] => 08 [y] => 243 ) [10] => Array ( [x] => 09 [y] => 242 ) [11] => Array ( [x] => 10 [y] => 244 ) [12] => Array ( [x] => 12 [y] => 243 ) [13] => Array ( [x] => 13 [y] => 243 ) [14] => Array ( [x] => 13 [y] => 243 ) [15] => Array ( [x] => 15 [y] => 243 ) ) x represent days and y values of a certain variable. I would like to display an array of unique days x ( last element ) and values y pragmatically. for example day 6 I have two y values but I want to display only the last one ( 243 ). Thanks for help

    Read the article

  • How to rotate a set of points on z = 0 plane in 3-D, preserving pairwise distances?

    - by cagirici
    I have a set of points double n[] on the plane z = 0. And I have another set of points double[] m on the plane ax + by + cz + d = 0. Length of n is equal to length of m. Also, euclidean distance between n[i] and n[j] is equal to euclidean distance between m[i] and m[j]. I want to rotate n[] in 3-D, such that for all i, n[i] = m[i] would be true. In other words, I want to turn a plane into another plane, preserving the pairwise distances. Here's my code in java. But it does not help so much: double[] rotate(double[] point, double[] currentEquation, double[] targetEquation) { double[] currentNormal = new double[]{currentEquation[0], currentEquation[1], currentEquation[2]}; double[] targetNormal = new double[]{targetEquation[0], targetEquation[1], targetEquation[2]}; targetNormal = normalize(targetNormal); double angle = angleBetween(currentNormal, targetNormal); double[] axis = cross(targetNormal, currentNormal); double[][] R = getRotationMatrix(axis, angle); return rotated; } double[][] getRotationMatrix(double[] axis, double angle) { axis = normalize(axis); double cA = (float)Math.cos(angle); double sA = (float)Math.sin(angle); Matrix I = Matrix.identity(3, 3); Matrix a = new Matrix(axis, 3); Matrix aT = a.transpose(); Matrix a2 = a.times(aT); double[][] B = { {0, axis[2], -1*axis[1]}, {-1*axis[2], 0, axis[0]}, {axis[1], -1*axis[0], 0} }; Matrix A = new Matrix(B); Matrix R = I.minus(a2); R = R.times(cA); R = R.plus(a2); R = R.plus(A.times(sA)); return R.getArray(); } This is what I get. The point set on the right side is actually part of a point set on the left side. But they are on another plane. Here's a 2-D representation of what I try to do: There are two lines. The line on the bottom is the line I have. The line on the top is the target line. The distances are preserved (a, b and c). Edit: I have tried both methods written in answers. They both fail (I guess). Method of Martijn Courteaux public static double[][] getRotationMatrix(double[] v0, double[] v1, double[] v2, double[] u0, double[] u1, double[] u2) { RealMatrix M1 = new Array2DRowRealMatrix(new double[][]{ {1,0,0,-1*v0[0]}, {0,1,0,-1*v0[1]}, {0,0,1,0}, {0,0,0,1} }); RealMatrix M2 = new Array2DRowRealMatrix(new double[][]{ {1,0,0,-1*u0[0]}, {0,1,0,-1*u0[1]}, {0,0,1,-1*u0[2]}, {0,0,0,1} }); Vector3D imX = new Vector3D((v0[1] - v1[1])*(u2[0] - u0[0]) - (v0[1] - v2[1])*(u1[0] - u0[0]), (v0[1] - v1[1])*(u2[1] - u0[1]) - (v0[1] - v2[1])*(u1[1] - u0[1]), (v0[1] - v1[1])*(u2[2] - u0[2]) - (v0[1] - v2[1])*(u1[2] - u0[2]) ).scalarMultiply(1/((v0[0]*v1[1])-(v0[0]*v2[1])-(v1[0]*v0[1])+(v1[0]*v2[1])+(v2[0]*v0[1])-(v2[0]*v1[1]))); Vector3D imZ = new Vector3D(findEquation(u0, u1, u2)); Vector3D imY = Vector3D.crossProduct(imZ, imX); double[] imXn = imX.normalize().toArray(); double[] imYn = imY.normalize().toArray(); double[] imZn = imZ.normalize().toArray(); RealMatrix M = new Array2DRowRealMatrix(new double[][]{ {imXn[0], imXn[1], imXn[2], 0}, {imYn[0], imYn[1], imYn[2], 0}, {imZn[0], imZn[1], imZn[2], 0}, {0, 0, 0, 1} }); RealMatrix rotationMatrix = MatrixUtils.inverse(M2).multiply(M).multiply(M1); return rotationMatrix.getData(); } Method of Sam Hocevar static double[][] makeMatrix(double[] p1, double[] p2, double[] p3) { double[] v1 = normalize(difference(p2,p1)); double[] v2 = normalize(cross(difference(p3,p1), difference(p2,p1))); double[] v3 = cross(v1, v2); double[][] M = { { v1[0], v2[0], v3[0], p1[0] }, { v1[1], v2[1], v3[1], p1[1] }, { v1[2], v2[2], v3[2], p1[2] }, { 0.0, 0.0, 0.0, 1.0 } }; return M; } static double[][] createTransform(double[] A, double[] B, double[] C, double[] P, double[] Q, double[] R) { RealMatrix c = new Array2DRowRealMatrix(makeMatrix(A,B,C)); RealMatrix t = new Array2DRowRealMatrix(makeMatrix(P,Q,R)); return MatrixUtils.inverse(c).multiply(t).getData(); } The blue points are the calculated points. The black lines indicate the offset from the real position.

    Read the article

  • dividing double by double gives weird results - Java

    - by Aly
    Hi, I am trying to do the following 33.33333333333333/100.0 to get 0.333333333333333 however when I run System.out.println(33.33333333333333/100.0); I get 0.33333333333333326 as the output, similarly when I run System.out.println(33.33333333333333/1000.0); I get 0.033333333333333326 as the output. Does anyone know why, and how I can get the correct value (without loss of decimal places). Thanks

    Read the article

  • in_array() and multidimensional array

    - by lauthiamkok
    I use in_array() to check whether a value exists in an array like below, $a = array("Mac", "NT", "Irix", "Linux"); if (in_array("Irix", $a)) { echo "Got Irix"; } //print_r($a); but what about an multidimensional array (below) - how can I check that value whether it exists in the multi-array? $b = array(array("Mac", "NT"), array("Irix", "Linux")); print_r($b); or I shouldn't be using in_array() when comes to the multidimensional array?

    Read the article

  • Need to add an array into another array at a specified key value

    - by sologhost
    Ok, I have an array like so, but it's not guaranteed to be laid out in this order all of the time... $array = array( 'sadness' => array( 'info' => 'some info', 'info2' => 'more info', 'value' => 'value', ), 'happiness' => array( 'info' => 'some info', 'info2' => 'more info', 'value' => 'the value', ), 'peace' => array( 'info' => 'some info', 'info2' => 'more info', 'value' => 'the value', ) ); Ok, and I'd like to throw in this array right after the happiness key is defined. I can't use the key of "peace" since it must go directly after happiness, and peace might not come after happiness as this array changes. So here's what I need to add after happiness... $another_array['love'] = array( 'info' => 'some info', 'info2' => 'more info', 'value' => 'the value of love' ); So the final output after it gets inputted directly after happiness should look like this: $array = array( 'sadness' => array( 'info' => 'some info', 'info2' => 'more info', 'value' => 'value', ), 'happiness' => array( 'info' => 'some info', 'info2' => 'more info', 'value' => 'the value', ), 'love' => array( 'info' => 'some info', 'info2' => 'more info', 'value' => 'the value of love', ), 'peace' => array( 'info' => 'some info', 'info2' => 'more info', 'value' => 'the value', ) ); Can someone please give me a hand with this. Using array_shift, array_pop, or array_merge doesn't help me at all, since these go at the beginning and at the end of the array. I need to place it directly after a KEY position within $array. Thanks :)

    Read the article

  • Why do you need float/double?

    - by acidzombie24
    I was watching http://www.joelonsoftware.com/items/2011/06/27.html and laughed at Jon Skeet joke about 0.3 not being 0.3. I personally never had problems with floats/decimals/doubles but then I remember I learned 6502 very early and never needed floats in most of my programs. The only time I used it was for graphics and math where inaccurate numbers were ok and the output was for the screen and not to be stored (in a db, file) or dependent on. My question is, where are places were you typically use floats/decimals/double? So I know to watch out for these gotchas. With money I use longs and store values by the cent, for speed of an object in a game I add ints and divide (or bitshift) the value to know if I need to move a pixel or not. (I made object move in the 6502 days, we had no divide nor floats but had shifts). So I was mostly curious.

    Read the article

  • PHP: Modifying array recursively?

    - by Industrial
    Hi everybody, I have tried to make a function that iterates through the following array to flatten it and add parent id to children, where applicable. I just can't make it work, so I hope that anyone here has an idea of what to do: Here's the starting point: Array ( [0] => Array ( [id] => 1 ) [1] => Array ( [id] => 2 [children] => Array ( [0] => Array ( [id] => 3 ) ) ) ) The expected result : Array ( [0] => array ( [id] => 1 ) [1] => array ( [id] => 2 ) [2] => array ( [id] => 3, [parent] => 2 ) ) Hope that anyone can point me in the right direction. Thanks a lot!

    Read the article

  • how to double buffer in multiple classes with java

    - by kdavis8
    I am creating a Java 2D video game. I can load graphics just fine, but when it gets into double buffering I have issues. My source code package myPackage; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; import java.awt.Toolkit; import java.awt.image.BufferStrategy; import java.awt.image.BufferedImage; import javax.swing.JFrame; public class GameView extends JFrame { private BufferedImage backbuffer; private Graphics2D g2d; public GameView() { setBounds(0, 0, 500, 500); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); backbuffer = new BufferedImage(getHeight(), getWidth(), BufferedImage.TYPE_INT_BGR); g2d = backbuffer.createGraphics(); Toolkit tk = Toolkit.getDefaultToolkit(); Image img = tk.getImage(this.getClass().getResource("cage.png")); g2d.setColor(Color.red); //g2d.drawString("Hello",100,100); g2d.drawImage(img, 100, 100, this); repaint(); } public static void main(String args[]) { new GameView(); } public void paint(Graphics g) { g2d = (Graphics2D)g; g2d.drawImage(backbuffer, 0, 0, this); } }

    Read the article

  • How to sort a date array in PHP

    - by Click Upvote
    I have an array in this format: Array ( [0] => Array ( [28th February, 2009] => 'bla' ) [1] => Array ( [19th March, 2009] => 'bla' ) [2] => Array ( [5th April, 2009] => 'bla' ) [3] => Array ( [19th April, 2009] => 'bla' ) [4] => Array ( [2nd May, 2009] => 'bla' ) ) I want to sort them out in the ascending order of the dates (based on the month, day, and year). What's the best way to do that? Originally the emails are being fetched in the MySQL date format, so its possible for me to get the array in this state: Array [ ['2008-02-28']='some text', ['2008-03-06']='some text' ] Perhaps when its in this format, I can loop through them, remove all the '-' (hyphen) marks so they are left as integars, sort them using array_sort() and loop through them yet again to sort them? Would prefer if there was another way as I'd be doing 3 loops with this per user. Thanks. Edit: I could also do this: $array[$index]=array('human'=>'28 Feb, 2009', 'db'=>'20080228', 'description'=>'Some text here'); But using this, would there be any way to sort the array based on the 'db' element alone? Edit 2: Updated initial var_dump

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >