You just need to add the second echo inside the IF
$array = array("http://proxy.lib.wayne.edu/login?url=http://accessanesthesiology.mhmedical.com", "http://proxy.lib.wayne.edu/login?url=http://accessmedicine.mhmedical.com","http://proxy.lib.wayne.edu/login?url=http://accesspharmacy.mhmedical.com", "http://proxy.lib.wayne.edu/login?url=http://accesssurgery.mhmedical.com", "http://online.statref.com/Default.aspx?grpalias=MLC", "http://www.biomedcentral.com");
foreach($array as $value) {
$pattern = '/^http?:\/\/proxy\.lib\.wayne\.edu\/login\?url=/';
if (preg_match($pattern, $value)) {
echo "<a href=$value>Database</a>";
}
else{
$value = "http://proxy.lib.wayne.edu/login?url=".$value;
echo "<a href=$value>Database</a>";
}
}
Edit added PHP soluition with dummy database
<?php
$resources = array();
// Add Resources to Array (fake DB)
array_push($resources, array(
'link' => 'http://proxy.lib.wayne.edu/login?url=http://accessanesthesiology.mhmedical.com',
'title' => 'AccessAnesthesiology (McGraw Hill)',
'text' => 'In AccessAnesthesiology, physicians and residents can access a compendium of medical resources, including exclusive procedural videos,
Custom Curriculum, and power search functionality, blended seamlessly with tables and charts designed for quick reference. Backed by an
esteemed advisory board, AccessAnesthesiology offers multiple tools for resident education and certification/recertification in pain
managements, critical care, and perioperative medicine.'
));
array_push($resources, array(
'link' => 'http://proxy.lib.wayne.edu/login?url=http://accessmedicine.mhmedical.com',
'title' => 'AccessMedicine',
'text' => 'A repository of medical knowledge from internal medicine, cardiology, genetics, pharmacy, diagnosis and management, basic sciences,
patient care, and more. Continuously expanding, all databases in the repository contain the latest editions of selected medical titles.'
));
array_push($resources, array(
'link' => 'http://proxy.lib.wayne.edu/login?url=http://accesspharmacy.mhmedical.com',
'title' => 'AccessPharmacy (AccessPharmacy)',
'text' => 'Users can search over 20 core curriculum textbooks, identify a core topic, or browse site by organ system. Case studies,
care plans, self-assessments and NAPLEX review help students develop and track key skills providing critical feedback for students and teachers.
Other features include information on clinical relevance and lab tests, comprehensive drug database, news & updates from Pharmacotherapy News
Network (PNN) and Goodman & Gilmans Pharmacological Basis of Therapeutics.'
));
array_push($resources, array(
'link' => 'http://proxy.lib.wayne.edu/login?url=http://accesssurgery.mhmedical.com',
'title' => 'AccessSurgery (McGraw-Hill)',
'text' => "McGraw-Hill's AccessSurgery.com is an integrated online resource that provides medical students, surgical residents, and practicing
surgeons with quick answers to surgical inquiries from trusted sources. Organized around the ACGME's (Accreditation Council for Graduate
Medical Education) mandate for a Core Curriculum, AccessSurgery delivers content in context."
));
array_push($resources, array(
'link' => 'http://online.statref.com/Default.aspx?grpalias=MLC',
'title' => 'ACP Pier: The physician information and education resource (STATRef)',
'text' => 'PIER is evidence-based clinical guidance presented electronically in a unique layered and telegraphic format.
It is designed for rapid access to clinical information at the point of care. PIER includes recommendations based
on all levels of medical evidence including RCTs, cohort and observational studies, case reports, and expert opinion.'
));
array_push($resources, array(
'link' => 'http://www.biomedcentral.com',
'title' => 'BioMed Central (Biomed Central)',
'text' => 'BioMed Central Ltd., an independent publisher in London, England, provides free access to biomedical research publications.
These publications include biology and medicine journal articles, current reports, and meeting abstracts. BioMed Central offers
information about current controlled trials, as well as topics in modern biology.'
));
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<html>
<head>
<title>Medical Library</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="library.css" />
</head>
<body>
<div id="wrapper">
<div id="header">
<h1>Electronic Resources</h1>
</div>
<div id="maincontent">
<div class="divimg">
<img src="medical.png" alt="Medical">
</div>
<?php foreach ($resources as $resource) : ?>
<?php
$pattern = '/^http?:\/\/proxy\.lib\.wayne\.edu\/login\?url=/';
if (!preg_match($pattern, $resource['link'])) $resource['link'] = "http://proxy.lib.wayne.edu/login?url=" . $resource['link'];
?>
<p><a href="<?php echo $resource['link']?>"><?php echo $resource['title'] ?></a></p>
<p><?php echo $resource['text']; ?></p>
<?php endforeach; ?>
</body>
</html>