Skip to content

Instantly share code, notes, and snippets.

View dethell's full-sized avatar

David Ethell dethell

View GitHub Profile
@dethell
dethell / viewWillDisappear
Last active August 29, 2015 14:04
Swift version of viewWillDisappear needed for custom storyboard back button behavior
override func viewWillDisappear(animated:Bool) {
if let currentViewControllers = self.navigationController.viewControllers as? [UIViewController] {
if let found = find(currentViewControllers, self) {
// Do nothing if the current controller is still in the stack. This means we're going forward, not back
}
else {
self.performSegueWithIdentifier("unwindToLogin", sender:self)
}
}
super.viewWillDisappear(animated)
@dethell
dethell / php-flatten.php
Created January 8, 2019 11:54
PHP Flatten Arrays
<?php
$array = [[1,2,[3]],4];
function returnValues($someArray, &$newArray) {
foreach ($someArray as $value) {
echo "checking value: " . print_r($value, true) . "<br/>\n";
if (is_array($value)) {
$values = returnValues($value, $newArray);
}
else {
echo "pushing value<br/>\n";