Forum Moderators: coopster
I have this code:
for ($i=0; $i<$count; $i++)
{
$topics = explode(";", $rowAR[$i]['topic']);
foreach ($topics as $topic)
{
$topicexpertAR[] = (array(ucfirst($topic),$rowAR[$i]['employeesID'],$rowAR[$i]['expert']));
}
}
The original text in the database is like this: "architectural history and theory; interior design history and theory; art history and theory", all lower-case unless a proper noun, and delimited by a semi-colon.
However, when I print from the array $topicexpertAR[], it ends up looking like this:
Topic ¦ Expert
Architectural history and theory ¦ Dr. Doctor
interior design history and theory ¦ Dr. Doctor
art history and theory ¦ Dr. Doctor
I have another record like this: "drug recalls by the FDA, etc., “pandemic” such as avian flu scare, west nile virus, etc." that ends up looking like this:
Topic ¦ Expert
drug recalls by the FDA, etc., “ ¦ Dr. Doctor
Pandemic” ¦ Dr. Doctor
such as avian flu scare, west nile virus, etc. ¦ Dr. Doctor
Is there something wrong with my code? Thanks for looking.
The capitalization problem is due to whitespace at the beginning of the string. There is a space after the semi-colon and that is the first character in the string. Therefore ucfirst() is trying to capitalize a blank space.
You could use ucfirst(trim($topic)).
Hope this helps