By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,049 Members | 1,308 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,049 IT Pros & Developers. It's quick & easy.

Looking for Optimization

P: n/a
hiya

I'd like to optimize a code snippet I wrote:

------------------------------------------------------------------------
while ($Girl = each($Girls)){
$AttGirl = "Attitude$Girl[value]";
if ($$AttGirl && ("-" != $$AttGirl))
$query .= " AND (swimsuits.attitude_" . strtolower($Girl[value]) . " = '" . $$AttGirl . "')";
}
------------------------------------------------------------------------

It would be quite cool if I could drop the second line. But I don't know
how to tackle this.
$Girls is a simple array:
$Girls = array('Ayane','Christie','Helena','Hitomi','Kasumi ','Leifang','Lisa','Tina');
It's quite possible that I'm on the wrong track and there's a much
cleaner approach. The above code resulted from optimizing this:

------------------------------------------------------------------------
if ($AttitudeAyane && ("-" != $AttitudeAyane))
$query .= " AND (swimsuits.attitude_ayane = '$AttitudeAyane')";
if ($AttitudeChristie && ("-" != $AttitudeChristie))
$query .= " AND (swimsuits.attitude_christie = '$AttitudeChristie')";
[repeat for other girls]
------------------------------------------------------------------------

$AttitudeAyane is defined elsewhere an may hold no value or something
along the lines of -,0,1,2,3,4 or 5
tsch
thomas
--
Music->Playing: In Strict Confidence - Herzattacke
Who am I? Am I the|As the silence fades away / I gather strength for another day
only me? I am the|Another day I've to go through / Another day here without you
only me... right? |-- "Another day", Lme Immortelle
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Thomas,

what about using $GLOBALS["Attitude" . $Girl["value"]]
instead of assigning and using $$AttGirl?

Greetings from Frankfurt / Germany,

Fabian Wleklinski
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.