Hy I have problem when retrieve data from database. I explode data but i can’t get lowercase.
Here’s the code
<?php
/*
This get records from database
*/
$items = Tekst::getReccords();
/*
this is function to explode data a get words with -
example:text from table These Is A Test
when exploded get These-Is-A-Test
I try everything to get small text strtolower doesnt' work
*/
function linkovi($tekst)
{
//$tekstovi = strtolower($tekst);
$links = explode(" ", $tekst);
foreach ($links as $key => $value) {
echo strtolower ($value)."-";
}
}
?>
<ul>
<?php foreach ($items as $item): ?>
<li><p><?php
linkovi($item->getNazivTeksta());
?>
</li>
<?php endforeach; ?>
</ul>
True only when that isn’t their stated purpose. The number of functions which actually echo something out should be very few. I’ve written more than one application with only one print statement in the entire thing.
But if I have a function called printArray() I should expect to see something echoed out.
echo toLowercase($array); ?! toLowercase should get a string.
You need
foreach ($array as $item) // or items, in case you need to work with your database items
toLowercase($item) – the string item, not the main array
You make your own purpose. Besides when you design a template engine (ie: smarty::display), I cannot imagine a method that should echo instead of return. It’s about architecture