Advertisement

07.04.2008 at 11:47PM PDT, ID: 23540379
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

Extracting lines from a file that meet a criteria

Asked by Simon336697 in PHP Scripting Language, Perl Programming Language, Shell Scripting

Hi guys hope u r well and can help.

I have a php file which has a list of entries in it like below...

------------------------------------------------------------------------------------- test1.php
 case 'menu3_it_cmswiki_joomla.php':
 case 'menu3_it_cmswiki_mediawiki.php':
 case 'menu3_it_databases_mysql.php':
 case 'menu3_it_drp_livestaterecovery.php':
 case 'menu3_it_drp_tivoli.php':
 case 'menu3_it_hware_dell.php':
 case 'menu3_it_hware_hp.php':
 case 'menu3_it_hware_ibm.php':
 case 'menu3_it_infrastructure_cml-swd.php':
 case 'menu3_it_messaging_im.php':
 case 'menu3_it_messaging_outlook.php':
 case 'menu3_it_microsoft_windows2003.php':
 case 'menu3_it_microsoft_windowsxp.php':
 case 'menu3_it_miscellaneous_notes.php':
 case 'menu3_it_network_cisco.php':
 case 'menu3_it_packaging_altiris.php':
 case 'menu3_it_packaging_wise.php':
 case 'menu3_it_virtual_vmware.php':
 case 'menu3_it_virtual_vpc.php':
 case 'menu3_it_unix_redhatlinux.php':
 case 'menu3_it_unix_suselinux.php':
---------------------------------------------------------------------------------------------

I have another file called placeinto.php.
From test1.php, Id like to insert entries from test1.php and place into placeinto.php at certain parts, or placeholders in placeinto.php

For example, part of placeinto.php looks like below.....note that currently, I have to hard code the below entries.

-------------------------------------------------------------------------- placeinto.php

//# ooIT-VIRTUALPLACEHOLDERoo1 #

              case 'menu3_it_virtual_vmware.php':
              case 'menu3_it_virtual_vpc.php':

//# ooIT-VIRTUALPLACEHOLDERoo2 #

 #########################################################

// #########################################################    
                                                               
//# ooIT-UNIXPLACEHOLDERoo1 #                                  
                                                               
                case 'menu3_it_unix_redhatlinux.php':
                case 'menu3_it_unix_suselinux.php':  
                                                               
//# ooIT-UNIXPLACEHOLDERoo2 #                                  
                                                               
// #########################################################  

----------------------------------------------------------------------------------------------
I hope from the above you can see what Im trying to do.
This file, has MULTIPLE PLACEHOLDERS as defined by eg. //# ooIT-UNIXPLACEHOLDERoo2 #  etc etc

Currently in placeinto.php, im hardcoding the case entries into specific parts of placeinto.php.
But these same entries, with your guys help, could be automatically inserted into the correct areas into placeinto.php, because they already exist in test1.php.

The following code works for placing one type of case entry pattern into the file.
I just dont know how to expand the functionality further so that if I have multiple placeholders, which I do in placeinto.php, how could I improve the below code, so that certain entries that meet the right criteria would popluate the correct placeholder in placeinto.php?

For example, if in test1.php..

case entries with menu3_it_hware would be placed into placeinto.php in between placeholder //# ooHWAREPLACEHOLDERoo1 # and //# ooHWAREPLACEHOLDERoo2 #
case entries with menu3_it_messaging would be placed into placeinto.php in between placeholder //# ooMESSAGINGPLACEHOLDERoo1 # and ooMESSAGINGPLACEHOLDERoo2 #
case entries with menu3_it_microsoft would be placed into placeinto.php in between placeholder //# ooMICROSOFTPLACEHOLDERoo1 # and //# ooMICROSOFTPLACEHOLDERoo2 #

Any help greatly appreciated.




Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
#!/usr/bin/php -q
<?php
 
$insert_it = file_get_contents("test1.php");
$template_it = file_get_contents("placeinto.php");
$place1_it = "//# ooITPLACEHOLDERoo1 #";
$place2_it = "//# ooITPLACEHOLDERoo2 #";
 
$x_it = explode($place1_it,$template_it);
// $template_part1 = $x[0] . $place1;
$template_part1_it = $x_it[0] . "\n" . $place1_it . "\n";
 
 
$x_it = explode($place2_it, $template_it);
// $template_part2_it = $place2_it . $x_it[1];
$template_part2_it = "\n" . $place2_it . "\n" . $x_it[1];
 
// $out_file_it = includes . '/' . $template_part1_it . $insert_it . $template_part2_it;
$out_file_it = $template_part1_it . $insert_it . $template_part2_it;
if (!file_put_contents("menu2_functions.php", $out_file_it)) { /* error processing */ }
 
 
?>
[+][-]07.05.2008 at 06:42AM PDT, ID: 21937062

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 06:47AM PDT, ID: 21937071

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 06:49AM PDT, ID: 21937075

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 06:58AM PDT, ID: 21937098

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 07:26AM PDT, ID: 21937171

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 07:34AM PDT, ID: 21937189

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 08:52AM PDT, ID: 21937414

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]07.05.2008 at 10:26AM PDT, ID: 21937716

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP Scripting Language, Perl Programming Language, Shell Scripting
Sign Up Now!
Solution Provided By: ahoffmann
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.05.2008 at 06:11PM PDT, ID: 21938965

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 06:19PM PDT, ID: 21938985

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.05.2008 at 06:27PM PDT, ID: 21939001

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.06.2008 at 08:45AM PDT, ID: 21940659

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628