I have a problem that someone might be able to help with. The following is a block of code from a project I am working on.

function Sniffer_INI() {
	$ia= ini_get_all();                   
echo "<table width='100%'>"; echo "<tr align='center' valign='middle'><th width='20%'><b>Key</b></th><th width='35%'><b>Global Value</b></th><th width='35%'><b>Local Value</b></th><th width='10%'><b>Access</b></th></tr>"; while(list($key, $value)= each($ia)) { echo "<tr align='middle'><td align='left'>" .$key ."</td><td align='center'>" .$ia[$key]['global_value'] ."</td><td align='center'>" .$ia[$key]['local_value'] ."</td><td align='center'>" .$ia[$key]['access'] ."</td></tr>"; } echo "</table>"; }

The block is a custom function, which retrieves the 2D array of information from ini_get_all(), and assigns it to $ia. From there, the code creates a table, and steps through each key, and its respective sub-array. Everything works nice and neat, except for one problem. When the code produces its result, and the output is merged with the web page template that the sites it will be used on runs, it breaks the template, because the resulting table is too wide. Even though I have sizes for each cell set, HTML overrides them, because at least one of the results from the sub-array is a long string of possible values, each seperated by commas. Downside, is the fact that since there is no spaces between each possible value, only the comma, HTML forces it to display on the same line. What I need to do, is find a way to force the information to split at the commas, into seperate lines.

This is the contents of the line that is giving me trobule, minus the last value, which is only a single digit number.

Key: url_rewriter.tags
Value 1: a=href,area=href,frame=src,input=src,form=fakeentry Value 2: a=href,area=href,frame=src,input=src,form=fakeentry

I need to split them on the commas, and list one piece on each line of the cell.

Thanks;
Dark Tempest

    from your text:

    
    $string="
    Key: url_rewriter.tags 
    Value 1: a=href,area=href,frame=src,input=src,form=fakeentr
    y Value 2: a=href,area=href,frame=src,input=src,form=fakeentr
    y";
    
    //get the lines
    preg_match_all('/value [0-9]+:.*?\s/i',$string,$line);
    for($i=0;$i<count($line[0]);$i++){
        $lineArray[$i]= $ine[0][$i];
    }
    //you have the lines, now get the pairs:
    foreach($lineArray as $n=>$v){
      preg_match_all('/[^,=]+=[^,=]/',$v,$pair);
      for($i=0;$i<count($pair[0]);$i++){
        $lineArray[$n][$i] = $pair[0][$i];
      }
    }[
    

    not sure if this is what you want

      Thanks for the thought, sfullman, I will try it out over the next day or two, and get back to you... In essence I need it to print all of the variables out, but when it hits that one, I need it to break the values down, on the commas, so that it shows each part of the value on a seperate line, within the same cell...

      IE;
      This:
      a=href,area=href,frame=src,input=src,form=fakeentry

      Will become this, inside of the right cell on the table:
      a=href
      area=href
      frame=src
      input=src
      form=fakeentry

      The rest of the table will display as normal. If you want, I can set up a demo of it, on a site I control, and let you take a peak at what I am upto...

      Thanks...

        to me it just seems you need to learn to use regular expressions, I have a tutorial at codewalkers.com (look for Sam Fullman), and there's a regex tester I developed at: www.samuelfullman.com

          I had tried trapping the line I wanted to split, with a if-else statement, then used explode to break it at the commas, but it didn't work, and didn't even show an error, even though I could walk the logic, and find no bugs, not even a missing semi-colon as I do every now and then... But will check out Code Walkers as well... I admit, I am still fairly new to PHP, and any tutorials are of help... 😃

          Here is a partial var dump of the array I am working with, I have highlighted the bit that I need to work on, but the rest of the array has to be displayed as well, hence why I put together the code block above.

          array(127) { ["allow_call_time_pass_reference"]=> array(3) { ["global_value"]=> string(0) "" ["local_value"]=> string(0) "" ["access"]=> int(6) } ["allow_url_fopen"]=> array(3) { ["global_value"]=> string(1) "1" ["local_value"]=> string(1) "1" ["access"]=> int(7) } ["always_populate_raw_post_data"]=> array(3) { ["global_value"]=> string(1) "0" ["local_value"]=> string(1) "0" ["access"]=> int(6) } ... ["session.entropy_length"]=> array(3) { ["global_value"]=> string(1) "0" ["local_value"]=> string(1) "0" ["access"]=> int(7) } ["session.gc_divisor"]=> array(3) { ["global_value"]=> string(4) "1000" ["local_value"]=> string(4) "1000" ["access"]=> int(7) } ["session.gc_maxlifetime"]=> array(3) { ["global_value"]=> string(4) "1440" ["local_value"]=> string(4) "1440" ["access"]=> int(7) } ["session.gc_probability"]=> array(3) { ["global_value"]=> string(1) "1" ["local_value"]=> string(1) "1" ["access"]=> int(7) } ["session.name"]=> array(3) { ["global_value"]=> string(9) "PHPSESSID" ["local_value"]=> string(9) "PHPSESSID" ["access"]=> int(7) } ["session.referer_check"]=> array(3) { ["global_value"]=> string(0) "" ["local_value"]=> string(0) "" ["access"]=> int(7) } ["session.save_handler"]=> array(3) { ["global_value"]=> string(5) "files" ["local_value"]=> string(5) "files" ["access"]=> int(7) } ["session.save_path"]=> array(3) { ["global_value"]=> string(4) "/tmp" ["local_value"]=> string(4) "/tmp" ["access"]=> int(7) } ["session.serialize_handler"]=> array(3) { ["global_value"]=> string(3) "php" ["local_value"]=> string(3) "php" ["access"]=> int(7) } ["session.use_cookies"]=> array(3) { ["global_value"]=> string(1) "1" ["local_value"]=> string(1) "1" ["access"]=> int(7) } ["session.use_only_cookies"]=> array(3) { ["global_value"]=> string(1) "0" ["local_value"]=> string(1) "0" ["access"]=> int(7) } ["session.use_trans_sid"]=> array(3) { ["global_value"]=> string(1) "0" ["local_value"]=> string(1) "0" ["access"]=> int(6) } ["short_open_tag"]=> array(3) { ["global_value"]=> string(1) "1" ["local_value"]=> string(1) "1" ["access"]=> int(6) } ["SMTP"]=> array(3) { ["global_value"]=> string(9) "localhost" ["local_value"]=> string(9) "localhost" ["access"]=> int(7) } ["smtp_port"]=> array(3) { ["global_value"]=> string(2) "25" ["local_value"]=> string(2) "25" ["access"]=> int(7) } ["sql.safe_mode"]=> array(3) { ["global_value"]=> string(0) "" ["local_value"]=> string(0) "" ["access"]=> int(4) } ["track_errors"]=> array(3) { ["global_value"]=> string(0) "" ["local_value"]=> string(0) "" ["access"]=> int(7) } ["unserialize_callback_func"]=> array(3) { ["global_value"]=> string(0) "" ["local_value"]=> string(0) "" ["access"]=> int(7) } ["upload_max_filesize"]=> array(3) { ["global_value"]=> string(2) "2M" ["local_value"]=> string(2) "2M" ["access"]=> int(6) } ["upload_tmp_dir"]=> array(3) { ["global_value"]=> NULL ["local_value"]=> NULL ["access"]=> int(4) } ["url_rewriter.tags"]=> array(3) { ["global_value"]=> string(51) "a=href,area=href,frame=src,input=src,form=fakeentry" ["local_value"]=> string(51) "a=href,area=href,frame=src,input=src,form=fakeentry" ["access"]=> int(7) } ["user_agent"]=> array(3) { ["global_value"]=> NULL ["local_value"]=> NULL ["access"]=> int(7) } ["user_dir"]=> array(3) { ["global_value"]=> string(0) "" ["local_value"]=> string(0) "" ["access"]=> int(4) } ...

          Dark Tempest...

            Write a Reply...