I have this query and function
$images = [];
$q = $pdo->query("SELECT * FROM projects ORDER BY project_id ASC LIMIT 8");
foreach($q as $row) {
$mainTitle1 = $row['project_category'];
$parts1=explode(" ",$mainTitle1);
$images[] = [
'project_category' => $row['project_category'],
'project_id' => $row['project_id'],
'project_image' => $row['project_image']
];
}
function image_html($image) {
return '<img src="'.$image['project_image'].'" alt="">';
}
function category($category) {
return '<span class="item-title">'.$parts1[0].'</span><span class="item-cat"> '.$parts1[1].'</span> ';
}
Which then I'm trying to display like this
<div class="itemm web">
<?php echo image_html($images[0]); ?>
<div class="item-overlay">
<?php echo category($images[0]); ?>
</div>
</div>
<div class="itemm w_60 web">
<?php echo image_html($images[1]); ?>
<div class="item-overlay">
<?php echo category($images[1]); ?>
</div>
</div>
<?php echo image_html($images[0]); ?> is showed correctly on the page but <?php echo category($images[0]); ?> it isn't. It's empty.
In database I have Name subname the idea is to show Name <span class="item-title">'.$parts1[0].'</span> and subname on <span class="item-cat"> '.$parts1[1].'</span>'
Why doesn't show anything?
$categorynot equal to $parts1