XpertWorlock Posted December 6, 2008 Share Posted December 6, 2008 Say if I have an array array = (Jeff,6,6) I have a loop happening, and when it gets to 6,6. $string1 = 6 $string2 = 6. How do I call up that array right than? Thanks Link to comment https://forums.phpfreaks.com/topic/135787-matching-array-with-string/ Share on other sites More sharing options...
shamuntoha Posted December 6, 2008 Share Posted December 6, 2008 if you mean to loop: for ($i=0; $i<6; $i++) { switch ($i) { case 5: echo "6 Times looped, call array": echo array[0].array[1].array[2]; break; } } or if u mean. foreach ($array in $key=>$value ) { if ($key == 2 ){ $array_scaned = true; } } Link to comment https://forums.phpfreaks.com/topic/135787-matching-array-with-string/#findComment-707563 Share on other sites More sharing options...
XpertWorlock Posted December 6, 2008 Author Share Posted December 6, 2008 Sorry don't mind the loop. I just need to know if $string1 = 6 and $string2 = 6. call up array (Jeff,6,6) Link to comment https://forums.phpfreaks.com/topic/135787-matching-array-with-string/#findComment-707566 Share on other sites More sharing options...
curtis Posted December 6, 2008 Share Posted December 6, 2008 What you're asking isn't quite making sense to me, but if I think I understand you right: <?php $list = array('Jeff', 6, 6); // strings equal 6 if ($string1 == '6' && $string2 == '6') { // do stuff with array } ?> You might want to consult some basic programming tutorials to learn things like boolean comparisons, among other things... Link to comment https://forums.phpfreaks.com/topic/135787-matching-array-with-string/#findComment-707570 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.