![]() |
![]() |
![]() |
||||
Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact us. |
![]() ![]() |
|
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed. |
|
Thread Tools |
![]() |
#1 |
Beer Money Baron
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
|
PHP Experts, Optimization question
Looking to optimize a lengthy switch/case statement. Working on something like this, and considering how to optimize it and speed it up. It's not that slow yet but it might be when it's finished.
Code:
switch($var) { case 'val1': $action = 'step1'; break; case 'val2': $action = 'step2'; break; .. and so on for about 200 more of these .. default: $action = 'do the hokey pokey'; break; }
__________________
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#2 |
Confirmed User
Join Date: Nov 2003
Posts: 158
|
if your $action are text/word try to put them in array() or store them in your database and call it in a limited query output
__________________
ICQ #228-338-185 |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#3 |
Confirmed User
Join Date: Nov 2005
Location: Edmonton, AB
Posts: 190
|
Yeah you could do like:
Code:
$actions['val1'] = 'step1'; $actions['val2'] = 'step2'; // Then, $action = $actions[$var]; Code:
// First, put the values into a mysql database like: value | action // Then, $action = @mysql_result(mysql_query('SELECT action FROM mySteps WHERE value=\''.mysql_escape_string($var).'\''),0); |
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#4 |
Confirmed User
Join Date: Sep 2001
Location: Boston
Posts: 4,873
|
fuck that get your host to install a PHP cache!
|
![]() |
![]() ![]() ![]() ![]() ![]() |
![]() |
#5 | |
Confirmed User
Join Date: May 2005
Posts: 2,737
|
Quote:
$method = 'some' . $action; if (method_exists(array(&$object, $method))) { $function->$method; } I would do something like that ... |
|
![]() |
![]() ![]() ![]() ![]() ![]() |