Looking for Optimization

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default Looking for Optimization

    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", L´âme Immortelle
    Thomas Neumann Guest

  2. Similar Questions and Discussions

    1. pdf optimization
      how to optimize pdf doc in c#
    2. 3D optimization
      HI All, I've made a 3D environment in lingo with Director MX, which uses some Havok physics - not much at the moment as I was concentrating on...
    3. Optimization Questions
      I have been looking at other web sites in my field that are high up on the search engines that don't use keywords or descriptions. Is there...
    4. FTP Performance Optimization
      :confused; We are trying to determine what exactly the "FTP Performance Optimization" setting does in the FTP window. Contribute defaults to this...
    5. Code optimization...
      This is a trick question right? I mean, you know that there is only one element in the rsc.SelectedIndexes, so how would you optimize the loop. ...
  3. #2

    Default Re: Looking for Optimization

    Hi Thomas,

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

    Greetings from Frankfurt / Germany,

    Fabian Wleklinski


    Fabian Wleklinski Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139