Adam McMurchie
Adam McMurchie

Reputation: 31

How to tidy up a messy echo statement

Hi guys im still relatively new to web design, and frustrated by only being able to pass my information i get from PHP, whilst in PHP - which forces me to use the echo statement. This in turn gets a bit messy as below:

echo  '<div class="jokes"> <p>' . $joke1[$x] . '</p><p class="meta"> uploader ' . $uploader[$x] . ' date: ' . $joke_date[$x] .' <p/> </div>' ;

What i would like is to have the word uploader in the meta tag in one color, and the PHP passed variable $uploader[$x] in another color. By adding more style tags i am getting a bit confused about keeping track of the points and quotes. Any suggestions?

Many thanks

Upvotes: 0

Views: 62

Answers (2)

Marin N.
Marin N.

Reputation: 366

This should give you a start:

<style>

 .blue { color: blue;}
 .red { color: red;}
</style>


<?php
echo  '<div class="jokes"> <p>' . $joke1[$x] . '</p><p class="meta"> <span class="blue">uploader</span> <span class="red">' . $uploader[$x] . '</span> date: ' . $joke_date[$x] .' <p/> </div>' ;

?>

Upvotes: 1

ShanjayG
ShanjayG

Reputation: 1023

You can try this

echo  '<div class="jokes"> <p>' . $joke1[$x] . '</p><p class="meta"> <span class="color-1">uploader </span><span class="color-2">' . $uploader[$x] . '</span> date: ' . $joke_date[$x] .' <p/> </div>' ;

And you can assign any color to the color-1 and color-2 class.

Upvotes: 1

Related Questions