Jump to content

jasonrichardsmith

Members
  • Posts

    19
  • Joined

  • Last visited

    Never

Posts posted by jasonrichardsmith

  1. <?php
    $string='this is a sentence with a load of [great, clever, textual] variables ';
    if(preg_match("/[[](.*)[]]/", $string, $matches)){
       $pieces = explode(", ", $matches[0]);
       foreach ($pieces as $value) {
          $replace = array( '[', ']' );
          $value = str_replace($replace,'',$value);
          echo "this is a sentence with a load of $value variables.<br>";
      }
    }
    else{
       print "no matches found";
    }
    ?>
    

     

    This works but I am guessing there is a more efficient way to not include the [] without doing a str_replace.

  2. I am not an authority on preg_match but this should be damn close to what you want.

    if(preg_match('#\[[^)]+\]#', $string, $matches)){
       $pieces = explode(", ", $matches[0]);
       foreach ($pieces as $value) {
          echo "this is a sentence with a load of $value variables.\n";
      }
    }
    else{
       print "no matches found";
    }

  3. I am not sure if this will fix your problem or not. I never tried this:

    usermod -G users www-data

     

    Then add the user option to fstab

    /dev/sda1        /foo/foo     ext3     user,noauto,umask=0002    0   0

     

    /foo/foo needs to change to your mount point and ext3 may not be the file system type.

    And /dev/sda1 may not be your device.

  4. Sorry should have checked it first.

    His callback "option" breaks its ability to work.

    replace this:

    <script type="text/javascript">
    $(document).ready(function() {
      $('span.countdown').countdown({seconds: 30,window.location.replace("visit.php")});
    });
    </script>

    with the following:

    <script type="text/javascript">
    
    $(document).ready(function() {
    
      $('#countdown').countdown({seconds: 5})
      setTimeout(function() {
      window.location.href = "visit.php";
    }, 5000);
    
    
    });
    
    
    </script>

    no his seconds are 5 which equals the 5000 milliseconds in the setTimeout.

     

    I just tested this and it works.

  5. paste this in a file named jquery.countdown.js

    /**
    * jQuery's Countdown Plugin
    *
    * display a countdown effect at given seconds, check out the following website for further information:
    * http://heartstringz.net/blog/posts/show/jquery-countdown-plugin
    *
    * @author Felix Ding
    * @version 0.1
    * @copyright Copyright(c) 2008. Felix Ding
    * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
    * @date 2008-03-09
    * @lastmodified 2008-03-09 17:48    		 
    * @todo error & exceptions handling
    */
    jQuery.fn.countdown = function(options) {
    /**
     * app init
    */	
    if(!options) options = '()';
    if(jQuery(this).length == 0) return false;
    var obj = this;	
    
    /**
     * break out and execute callback (if any)
     */
    if(options.seconds < 0 || options.seconds == 'undefined')
    {
    	if(options.callback) eval(options.callback);
    	return null;
    }
    
    /**
     * recursive countdown
     */
    window.setTimeout(
    	function() {
    		jQuery(obj).html(String(options.seconds));
    		--options.seconds;
    		jQuery(obj).countdown(options);
    	}
    	, 1000
    );	
    
    /**
         * return null
         */
        return this;
    }

     

     

    Put this at the top of your page

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
    <script type="text/javascript" src="put.the.path.to.jquery.file.you.just.created"></script>

     

    Put this on the bottom of you page.  I put all javascript on the bottom of the page per the Jquery cookbooks suggestion.

     

    <script type="text/javascript">
    $(document).ready(function() {
      $('span.countdown').countdown({seconds: 30,window.location.replace("visit.php")});
    });
    </script>
    

     

    replace 30 with however long you want.

     

     

    keep this

    echo 'You\'ll be redirected in <span id="countdown"></span> secs. If not, click <a href="visit.php">here</a></div>.';

     

    this should do everything for you

  6. I have a soap client written up that works well on small requests, but on large ones I face out of memory issues.

     

    I want to be able to write the response directly to a file as an xml document, so I can use something like xpath.

     

    When I try this even on small responses it seems to go into a loop:

      $infile = $client->Retrieve($criteria);

      $outfile = fopen('./sites/all/modules/cvent/data.txt', 'w');

      while (!feof($infile)) {

        fwrite($outfile, fread($infile, 2048));

        }

     

    how can I put the data into a file straight from the response and still be economical on memory?

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.