RobertSubnet Posted March 8, 2009 Share Posted March 8, 2009 Greetings all. I have a web site that uses long option lists and switch cases. Both of these use numerical sequences. When I make a change, re-ordering is a very long and tedious process. For example: 1 => apple 2 => pear 3 => grape 4 => banana ------------- Insert orange in the #2 spot 1 => apple 2 => orange 3 => pear 4 => grape 5 => banana Here the re-ordering is easy. But in my scripts, I have close to 200 options/switch cases. What I am wondering is can I use str_replace() combined with a while loop to automate the process? With the subject (input file) being along the lines of: $subject = './myfile.php'; Thanks, ~Robert Quote Link to comment https://forums.phpfreaks.com/topic/148490-str_replace-with-a-text-file/ Share on other sites More sharing options...
premiso Posted March 8, 2009 Share Posted March 8, 2009 Why not just have each entry in the text file comma separated, then you open that file with file and sort the array how you want? It seems you are going about this the long way. Instead of the switch, you can use in_array Quote Link to comment https://forums.phpfreaks.com/topic/148490-str_replace-with-a-text-file/#findComment-779754 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.