serialization - Trying to simplify my php code (serialize) -


Data is hiding on one side if the data is zero, my php code (bottom) works but all with me There are 240 lines, and I think there should be a way to simplify.

Here is an example of a code:

  if (trim ($ globals ["s101"])) {} else {echo} style style = 'text / Css' & gt; # S101 {Performance: None} & lt; / Style & gt; ";}; If (trim ($ globals ["s102"]) {} else {echo "style = type = 'text / css' & gt; # s102 {display: none} "; }; If (trim ($ globals ["s103"])) {} else {echo "style = type = 'text / css' & gt; # s103 {display: none} & lt; / style & gt;"; }; If (trim ($ globals ["s104"])) {} else {echo "style = type = 'text / css' & gt; # s104 {display: none} "; }; If (trim ($ globals ["s105"])) {} else {echo "style = type = 'text / css' & gt; # s105 {display: none} "; }; If (trim ($ globals ["s106"])) {} else {resonant "style = type = 'text / css' & gt; # s106 {display: none} & lt; / style & gt;"; };  

The general characteristics of the above elements are square. Section

So, my question is this: can one line change all the lines above, and what will it be? Thanks for your help!

You should not use $ GLOBALS . What you might be doing, all of these items are being placed in an array instead of a series of 240 different variables.

Then create an array, call it $ s_array .

You can easily loop on the array on the output:

  foreach ($ s_array as $ value) {echo '& lt; Style type = "text / css" & gt; '. $ Value '{display: none} & lt; / Style> '; }  

Or even better, you define a CSS class and prevent the madness of all repeat style blocks. Then apply that class to all the DOM elements, which you are currently specifying CSS styles by ID.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -