Jump to content
php.lv forumi

meklēt masīva elementā daļu


jam

Recommended Posts

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

<?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

<?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

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

×
×
  • Create New...