d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Php - Color Whole Array Output ?
Add Reply New Topic New Poll
Member
Posts: 2,182
Joined: Dec 18 2006
Gold: 312.49
Sep 12 2013 03:00pm
hi :) so i have an init.php in which i declare

$errors = array();

i include this init.php on every page, so whenever i have to output an error i just write $error[] = 'blabla whatever';

now i have an error_output function which looks like this:

function output_errors($errors) {
return '<ul><li>' . implode('</li><br><li>', $errors) . '</li></ul><br>';
}
( if there are more errors they will be sorted in a list )

however i can't manage to get the output in the color red

"<div class=\"red \">$variable</div>";
and
<font ...... </font>
did NOT work ( i know you shouldn´t use inline font however it ALSO didnt work

hopefully you guys will throw some ideas in since i don't want to set the color on each individual page :)

Thx in advance :)
Member
Posts: 29,723
Joined: Jun 11 2007
Gold: 279.52
Sep 12 2013 04:01pm
well your wiritng the html wrong.

inline styles are written

'<li style="color:red">',$errors)

if your writing it as a class you need to name the class:
'<li class="error">,$errors)

then tell that class what to do in an external style sheet or at the top of the document, classes start with a period and call it like this:

.error {
color:red;
}

as for your array implode, i would implode as minimal markup as possible, you dont want to get confused where you wrote your markup and php.
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Sep 13 2013 02:19am
You should really learn intermediate HTML and CSS before you go into PHP.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 13 2013 06:07am
Quote (eagl3s1ght @ Sep 13 2013 04:19am)
You should really learn intermediate HTML and CSS before you go into PHP.


havent seen you around here in a long time. figured you quit jsp and did something productive with your time O.o
Member
Posts: 827
Joined: Jan 16 2012
Gold: 0.00
Warn: 10%
Sep 13 2013 11:42am
Quote (carteblanche @ Sep 13 2013 10:07am)
havent seen you around here in a long time. figured you quit jsp and did something productive with your time O.o


kkkkkkkkkk, probably trolling somewhere else. hahahaha
Member
Posts: 2,182
Joined: Dec 18 2006
Gold: 312.49
Sep 14 2013 09:51am
ahh thanks AkuuZ :)
Member
Posts: 2,736
Joined: Nov 28 2009
Gold: 34.00
Sep 14 2013 12:57pm
Quote (tassi @ 14 Sep 2013 17:51)
ahh thanks AkuuZ :)


You're welcome for the tip that you should learn HTML+CSS before PHP.
Member
Posts: 62,873
Joined: Aug 2 2009
Gold: 1,189.90
Sep 15 2013 12:41am
Quote (eagl3s1ght @ Sep 13 2013 01:19am)
You should really learn intermediate HTML and CSS before you go into PHP.


Seconded.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll