jam Posted October 20, 2005 Report Share Posted October 20, 2005 Man ir masīvs $mazivs = array("1-uuc_mc","2-aac_gf","3-dfasd_der","uttttttt"); ir variablis $xx = "uuc_mc"; Vajag meklēt masīvā to elementu, kurš ietver to $xx un atgriezt to visu, tb kaut kas līdzīgs select elements.array from array where elements like '%uuc_mc%' Kā to izdarīt? Link to comment Share on other sites More sharing options...
Kristabs Posted October 20, 2005 Report Share Posted October 20, 2005 <?php $mazivs = array("3-dfasd_der","1-uuc_mc","3-dfasd_der","uttttttt"); $xx = "uuc_mc"; $c = count($mazivs); $i = 0; while($i<$c){ if (eregi($xx, $mazivs[$i])) { echo "Masīva <b>".$i."</b>ais elements satur \"".$xx."\""; } $i++; } echo "<br><h4>Viss info par masīvu: </h4><br>"; print_r($mazivs); ?> Link to comment Share on other sites More sharing options...
jam Posted October 20, 2005 Author Report Share Posted October 20, 2005 Man nevajag masīva kārtas nr, bet tieši elementu, ja varētu :) Link to comment Share on other sites More sharing options...
jam Posted October 20, 2005 Author Report Share Posted October 20, 2005 Pardon, pats jau sapratu. Paldies. Link to comment Share on other sites More sharing options...
bubu Posted October 20, 2005 Report Share Posted October 20, 2005 Pēc kārtas numura nemāki elementu dabūt? eregi vietā labāk lietot strpos, būs kudi ātrāk un efektīvāk. Link to comment Share on other sites More sharing options...
Roze Posted October 21, 2005 Report Share Posted October 21, 2005 A kapēc ne array_search http://lv.php.net/array_search vai arī array_keys ar Search parametru? Link to comment Share on other sites More sharing options...
jam Posted October 21, 2005 Author Report Share Posted October 21, 2005 <?php if (eregi($xx, $mazivs[$i])) { echo "Masīva <b>".$i."</b>ais elements satur \"".$xx."\""; } $i++; } echo "<br><h4>Viss info par masīvu: </h4><br>"; print_r($mazivs); ?> 25141[/snapback] Shaize, shitais eregi atrod arii visus ,kuri satur mekleejamo,rrr. Ja man ir araijaa SGN_606M un SGN_606MEX ,tad, ja $xx = 'SGN_606M' , protams, ka tiks atrasts SGN 606MEX. Kaa lai pasaka, ka lai meklē elementos no beigaam vai kaa savaadaak to apiet? Link to comment Share on other sites More sharing options...
Kristabs Posted October 21, 2005 Report Share Posted October 21, 2005 preg_match - eregi vietaa Link to comment Share on other sites More sharing options...
jam Posted October 21, 2005 Author Report Share Posted October 21, 2005 preg_match - eregi vietaa 25188[/snapback] Kā tās funkcijas visas var galvā paturēt :)) Link to comment Share on other sites More sharing options...
Roze Posted October 21, 2005 Report Share Posted October 21, 2005 Kā tās funkcijas visas var galvā paturēt :)) 25189[/snapback] Nu pag valoda paliek valoda.. pie kam salīdzinot ar reālajām šeit "vārdiņu" ir krietni krietni mazāk, kā arī uzbūve un likumi krietni vienkāršāki :) Link to comment Share on other sites More sharing options...
bubu Posted October 21, 2005 Report Share Posted October 21, 2005 preg_match - eregi vietaa 25188[/snapback] Saderam, ka var ar to pašu eregi uzrakstīt. Link to comment Share on other sites More sharing options...
jam Posted October 21, 2005 Author Report Share Posted October 21, 2005 Davai saderiet un uzrakstiet, lai man tas preg_replace straadaa. Link to comment Share on other sites More sharing options...
bubu Posted October 21, 2005 Report Share Posted October 21, 2005 Davai atver manuāli un palasi bišķi pirms katra teikuma, ko te ieklabini. Link to comment Share on other sites More sharing options...
jam Posted October 21, 2005 Author Report Share Posted October 21, 2005 Davai atver manuāli un palasi bišķi pirms katra teikuma, ko te ieklabini. 25224[/snapback] Nu labi labi maaaaaaaster, piedod ak jel varenais kungs, ka kluudijos un uzrakstiiju preg_match vietaa preg_replace Link to comment Share on other sites More sharing options...
bubu Posted October 21, 2005 Report Share Posted October 21, 2005 Ne jau par to ir runa... Link to comment Share on other sites More sharing options...
Recommended Posts