function walk(&$a) { foreach ($a as $i => $v) { if (is_array($v) && array_values($v) !== $v) { walk($a[$i]); } else { // Get type $t = gettype($v); // Parse type name $t = str_replace(array('boolean', 'double'), array('bool', 'float'), $t); // Check date type if (Toml::isISODate($v)) { $t = 'datetime'; } // Fix double vs integer type if ($t == 'float' && $v == intval($v)) { $t = 'integer'; } // Parse array type if ($t == 'array') { walk($v); } else { $v = "{$v}"; } $a[$i] = array('type' => $t, 'value' => $v); } } }
public function testParseMultiLineArrayTrailingComma() { $p = Toml::parse('test = [ "lorem", "ipsum", ]'); $this->assertEquals(array("lorem", "ipsum"), $p['test']); }
/** * Helper function for parsing Toml strings * or files. * * @param string $toml Specifies the Toml * formatted String or * the path to a Toml file * to be parsed. */ function parse($toml) { if (!is_string($toml)) { throw new \InvalidArgumentException('Please specify a Toml formatted String or a file path to a Toml document'); } $path = pathinfo($toml); if (isset($path['extension']) && strtolower($path['extension']) == 'toml') { return Toml::parseFile($toml); } return Toml::parse($toml); }
<?php require "../src/Toml.php"; Toml::parseFile('example.toml');
My interests include technology, computers, programming, music, video games, graphic design and automotive. I do have more interests, but the ones I listed are what I mostly spend my free time on. Since the CST program, my interest in programming has increased significantly. It's an activity I really enjoy doing. Programming gives me a sense to express creativity, thought process and control.<br /> <br /> My current strengths and knowledge with programming are Web Development, Graphic Design, Databases, Object-Oriented and Imparitive Programming. There are lots of areas that I wish to explore like Operating Systems, Language Design, Functional Programming, etc but I do find those areas quite intimidating at my current level. As I spend more time reading, experimenting and exploring new topics I have little or no knowledge in, it becomes a matter of applying myself to spend the time in learning those topics. I would love to learn everything I can, but there's so much knowledge out there, it can be difficult to focus on one topic for awhile. It's not a matter of getting bored with one topic and moving on, but since there's so much to learn, it can be overwhelming. In the long run, the knowledge I gain will be beneficial in my future endeavors.</p> </section> <section id="education" class="container"> <h2>Education</h2> <h3>Camosun College: 2013 - 2015</h3> <h4>Computer Systems Techology</h4> <p><span style="font-size:20px;">Courses Completed:</span></p> <div id="courses"> <?php $courses = Toml::parseFile('share/courses.toml'); foreach ($courses['courses'] as $key => $value) { echo "<p>{$key}: {$value}</p>"; } ?> </div> </section> <section id="languages" class="container"> <h2>Programming Languages</h2> <div class=""> <ul> <li class="head">PHP</li>
public function testCommentAtMultilineArray() { $p = Toml::parse("test = [\n1,\n2 # test\n]"); $this->assertEquals(array('test' => array(1, 2)), $p); }
public function testLiteralString() { $p = Toml::parse('title = \'C:\\Users\\nodejs\\templates\''); $this->assertEquals(array('title' => 'C:\\Users\\nodejs\\templates'), $p); }
public function testZeroInt() { $p = Toml::parse('test = 0'); $this->assertEquals(0, $p['test']); }
public function testEmptyNestedTable() { $p = Toml::parse("[test.alpha]"); $this->assertEquals(array('test' => array('alpha' => null)), $p); }