i have an array. i need to print it. can anyone help me ? my code is. $req['mysql'] = 'Mysql Version'; $req['php'] = 'PHP Version >= 4.1.0 :'; if (!version_compare("4.1.0", phpversion(), "<=")) { $errors[] = '<img src="images/error.gif" /> Your PHP version'.phpversion().' is incompatible with this script.'; } else { $text[] = '<img src="images/tick.gif" /> Your PHP version'.phpversion().' is compatible with this script.'; } if (find_SQL_Version() <="4.1.0") { $errors[] = '<img src="images/error.gif" /> MySQL Support: Your MySQL version'.find_SQL_Version().' is incompatible with this script.'; } else { $text[] = '<img src="images/tick.gif" /> MySQL Support: Your MySQL version'.find_SQL_Version().' is compatible with this script.'; foreach($req as $reqs) { echo '<div class="list">'; echo '<ul>'; while (list($key,$value) = each($errors)) { if (empty($value)) { } else { echo "<li>".$reqs."".$value."</li>"; } } while (list($key,$value) = each($text)) { if (empty($value)) { } else { echo "<li>".$reqs."".$value."</li>"; } } echo "</ul>"; echo '</div>'; } } PHP: it isnt working, it is just printing mysql version again and again on the output. can anyone help me?
Should be: $req[0] = array('php','PHP Version >= 4.1.0 :'); $req[1] = array('mysql','Mysql Version'); if (!version_compare("4.1.0", phpversion(), "<=")) { $errors[0] = '<img src="images/error.gif" /> Your PHP version'.phpversion().' is incompatible with this script.'; } else { $text[0] = '<img src="images/tick.gif" /> Your PHP version'.phpversion().' is compatible with this script.'; } if (find_SQL_Version() <="4.1.0") { $errors[1] = '<img src="images/error.gif" /> MySQL Support: Your MySQL version'.find_SQL_Version().' is incompatible with this script.'; } else { $text[1] = '<img src="images/tick.gif" /> MySQL Support: Your MySQL version'.find_SQL_Version().' is compatible with this script.'; foreach($req as $sub => $item){ echo '<div class="list">'; echo '<ul>'; echo "<li>".$sub[0]."".$errors[$sub].$text[$sub]."</li>"; echo '</ul>'; echo '</div>'; } PHP: Peace,
lol no , u are doing it wrong , it cant be : else { $text[1] = '<img src="images/tick.gif" /> MySQL Support: Your MySQL version'.find_SQL_Version().' is compatible with this script.'; foreach($req as $sub => $item){ echo '<div class="list">'; echo '<ul>'; echo "<li>".$sub[0]."".$errors[$sub].$text[$sub]."</li>"; echo '</ul>'; echo '</div>'; } or it will only execute the foreach thing if sql version will be lower than "4.1.0"