IMPORTANT!

Snipt is going open source. We've toyed with this idea for quite a while, and have finally decided it's the right way to move forward.

A few things:
  • The entire Snipt source code will be released on GitHub under the 3-clause BSD License on Friday, September 10th.
  • While we'd like to think we're perfect, we realize we're only human. By open sourcing the software that runs this website, certain bugs or security flaws may be discovered that could compromise the privacy of your snipts.
  • Only the Lion Burger team will be able to push commits to the Snipt.net site. Contributors should send a pull request to add new features or submit patches.
  • By using this site, you agree not to be too angry or take any legal action against Lion Burger should this whole thing go up in flames some day.
  • Follow us on Twitter for updates.
I agree, close this message
Sign up to create your own snipts, or login.

Latest 100 public snipts » yml The latest public yml snipts.

showing 1-2 of 2 snipts for yml
  • PHP reads from text file and write into YML file
    <?
    $arr=file("province.txt");// the txt file to be read
    // read the data from province.txt and write into 02_district.yml
    $myFile = "02_district.yml"; 
    //open a new file with name $myFile, if permission is dennied, throws message
    $fh = fopen($myFile, 'w') or die("can't open file");
    // write the head in YML file without backspace
    $head= "District:\n";
    fwrite($fh, $head);
    $i = 0;
    $k = 0;
    $tmp = "province";
    foreach($arr as $str)
    {
      $k++;
      // split $str, if digits were found
      list($province,$district)=preg_split("/[\d]+/", $str);;
      /*echo "<ul>";
      echo "<li>".$province;
      echo "<li>".$district;
      echo "</ul>";
      echo "<hr>";*/
    
      $district_id = "  District_".$k.":\n";// \n change line
      $district_name = "    name:  ".$district."";
      if($tmp != $province){//if province is changed, increase the id of province
    	  $i++;  
    	  $tmp = $province;
      }
      $province_id = "    province_id:  Province_".$i."\n";
      fwrite($fh, $district_id);//write the value in file
      fwrite($fh, $district_name);
      fwrite($fh, $province_id);
    }
    fclose($fh);
    
    ?> 
    
    // this is text file to be read by PHP script
    Nuristan	3001	Nuristan
    Nuristan	3002	Kamdesh
    Nuristan	3003	Waygal
    Nuristan	3004	Mandol
    Nuristan	3005	Bargi Matal
    Nuristan	3006	Wama
    Nuristan	3007	Du Ab
    Nuristan	3008	Nurgaram
    Sari Pul	3101	Sari Pul
    Sari Pul	3102	Sangcharak
    Sari Pul	3103	Kohistanat
    Sari Pul	3104	Balkhab
    Sari Pul	3105	Sozma Qala
    Sari Pul	3106	Sayyad
    Sari Pul	3107	Gosfandi
    

    copy | embed

    0 comments - tagged in  posted by toledot on Jan 28, 2010 at 2:05 p.m. EST
  • symfony database yml config
    all:
      propel: #database name in schema.xml
        class:                sfPropelDatabase
        param:
          phptype:            mysql     # Database vendor
          hostspec:           localhost
          database:           blog
          username:           login
          password:           passwd
          encoding:           utf8      # Default charset for table creation
          persistent:         true      # Use persistent connections
    

    copy | embed

    0 comments - tagged in  posted by mel28 on Feb 09, 2009 at 6:13 a.m. EST
Sign up to create your own snipts, or login.