bftwofreak Posted September 11, 2008 Share Posted September 11, 2008 I have about 16 arrays on one page and I've written an if statement. For example: The arrays that it searches through are named $p1['tag'] through $p16['tag']. Basically how do I search through those arrays and use that same array to add a var under that array? if someone can point me in the right direction I'm sure I can figure it out. Thanks! Link to comment https://forums.phpfreaks.com/topic/123701-replacing-a-specific-array/ Share on other sites More sharing options...
bftwofreak Posted September 11, 2008 Author Share Posted September 11, 2008 the search will go through the variables in the array and look for $name, and if it finds it, it will put it into the same array that it came from. However it will be under a different array and that variable under every other array will have a specific variable. Link to comment https://forums.phpfreaks.com/topic/123701-replacing-a-specific-array/#findComment-638757 Share on other sites More sharing options...
discomatt Posted September 11, 2008 Share Posted September 11, 2008 You aren't making much sense, but here's how you can loop though your arrays <?php for ( $i=1;$i<17;$i++ ) { $var = 'p'.$i; if ( ${$var}['tag'] == $name ) { # dunno what you wanna do here } } ?> Link to comment https://forums.phpfreaks.com/topic/123701-replacing-a-specific-array/#findComment-638797 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.