/** * @see Command */ protected function execute(InputInterface $input, OutputInterface $output) { $doctrine = $this->getContainer()->get('doctrine'); $em = $doctrine->getManager(); $name = $input->getArgument('name'); $system = $input->getArgument('system'); /* @var RepositoryInterface $roleRepository */ $repository = $this->getContainer()->get('sulu.repository.role'); $role = $repository->findOneByName($name); if ($role) { $output->writeln(sprintf('<error>Role "%s" already exists.</error>', $name)); return 1; } /** @var RoleInterface $role */ $role = $repository->createNew(); $role->setName($name); $role->setSystem($system); $pool = $this->getContainer()->get('sulu_admin.admin_pool'); $securityContexts = $pool->getSecurityContexts(); // flatten contexts $securityContextsFlat = []; array_walk_recursive($securityContexts['Sulu'], function ($value) use(&$securityContextsFlat) { $securityContextsFlat[] = $value; }); foreach ($securityContextsFlat as $securityContext) { $permission = new Permission(); $permission->setRole($role); $permission->setContext($securityContext); $permission->setPermissions(127); $role->addPermission($permission); } $em->persist($role); $em->flush(); $output->writeln(sprintf('Created role "<comment>%s</comment>" in system "<comment>%s</comment>".', $role->getName(), $role->getSystem())); }
public function search_articles($q, $topic_ids = null, $page = 1, $limit = 20, $is_recommend = false) { if ($topic_ids) { $topic_ids = explode(',', $topic_ids); array_walk_recursive($topic_ids, 'intval_string'); $where[] = '`id` IN (SELECT `item_id` FROM ' . $this->get_table('topic_relation') . ' WHERE topic_id IN(' . implode(',', $topic_ids) . ') AND `type` = "article")'; } if ($is_recommend) { $where[] = '(`is_recommend` = "1" OR `chapter_id` IS NOT NULL)'; } if ($where) { $where = implode(' AND ', $where); } $search_hash = $this->get_search_hash('article', 'title', $q, $where); if (!($result = $this->fetch_cache($search_hash))) { if ($result = $this->query_all($this->bulid_query('article', 'title', $q, $where), $this->max_results)) { $result = aasort($result, 'score', 'DESC'); } else { return false; } $this->save_cache($search_hash, $result); } if (!$page) { $slice_offset = 0; } else { $slice_offset = ($page - 1) * $limit; } return array_slice($result, $slice_offset, $limit); }
public static function array_map_recursive($func, $arr) { array_walk_recursive($arr, function (&$w) use($func) { $w = $func($w); }); return $arr; }
function motopressCEJsonEncode($array) { //convmap since 0x80 char codes so it takes all multibyte codes (above ASCII 127). So such characters are being "hidden" from normal json_encoding $options = array('convmap' => array(0x80, 0xffff, 0, 0xffff), 'encoding' => 'UTF-8'); array_walk_recursive($array, 'motopressCEMbEncodeNumericentity', $options); return mb_decode_numericentity(json_encode($array), $options['convmap'], $options['encoding']); }
/** * Renders a template. * * @param mixed $name A template name or a TemplateReferenceInterface instance * @param array $parameters An array of parameters to pass to the template * * @return string The evaluated template as a string * * @throws \RuntimeException if the template cannot be rendered * * @api */ public function render($name, array $parameters = array()) { $objectConverter = $this->objectConverter; $legacyVars = array(); foreach ($parameters as $varName => $param) { // If $param is an array, we recursively convert all objects contained in it (if any). // Scalar parameters are passed as is if (is_array($param)) { array_walk_recursive($param, function (&$element) use($objectConverter) { if (is_object($element) && !$element instanceof LegacyCompatible) { $element = $objectConverter->convert($element); } }); $legacyVars[$varName] = $param; } else { if (!is_object($param) || $param instanceof LegacyCompatible) { $legacyVars[$varName] = $param; } else { $objectConverter->register($param, $varName); } } } $legacyVars += $objectConverter->convertAll(); return $this->getLegacyKernel()->runCallback(function () use($name, $legacyVars) { $tpl = eZTemplate::factory(); foreach ($legacyVars as $varName => $value) { $tpl->setVariable($varName, $value); } return ezpEvent::getInstance()->filter('response/output', $tpl->fetch($name)); }, false); }
/** * @param $blueprint * * @return array * @throws \InvalidArgumentException */ protected function parseBlueprint($blueprint) { $callback = function (&$value) { if (is_string($value)) { $value = str_replace(':current', '*', $value); } if ($value[0] === ':') { # structure $structure = $this->getStructure($value); $value = $this->parseBlueprint($structure); return; } if (strpos($value, '|') === false) { return; } $parts = preg_split('/\\s?\\|\\s?/', $value); $selector = array_shift($parts); $value = ApistConf::select($selector); foreach ($parts as $part) { $this->addCallbackToFilter($value, $part); } }; if (!is_array($blueprint)) { $callback($blueprint); } else { array_walk_recursive($blueprint, $callback); } return $blueprint; }
/** * array_map_recursive, which is missing from PHP, with the same signature * * @param callable $func * @param array $arr * * @return array */ public static function arrayMapRecursive(callable $func, array $arr) { array_walk_recursive($arr, function (&$v) use($func) { $v = $func($v); }); return $arr; }
public function get_feature_by_id($feature_id) { if (!$feature_id) { return false; } if (is_array($feature_id)) { $feature_ids = $feature_id; if (sizeof($feature_ids) == 0) { return false; } } else { $feature_ids[] = $feature_id; } array_walk_recursive($feature_ids, 'intval_string'); if ($features = $this->fetch_all('feature', 'id IN (' . implode(',', $feature_ids) . ')')) { foreach ($features as $key => $val) { if (!$val['url_token']) { $features[$key]['url_token'] = $val['id']; } $data[$val['id']] = $features[$key]; } } if (is_array($feature_id)) { return $data; } else { return $data[$feature_id]; } }
/** * Magic function which handles the properties accessibility. * @param string $propertyName The property name. */ public function __get($propertyName) { switch ($propertyName) { default: $value = null; // Get - Post - Cookie. if (array_key_exists($propertyName, $_GET)) { $value = $_GET[$propertyName]; } else { if (array_key_exists($propertyName, $_POST)) { $value = $_POST[$propertyName]; } else { if (array_key_exists($propertyName, $_COOKIE)) { $value = $_COOKIE[$propertyName]; } } } // Case of an array. if (is_array($value)) { array_walk_recursive($value, array($this, 'cleanValue')); return $value; } // Else. return $this->cleanValue($value); } }
/** * Shutdown event * * @param \Cake\Event\Event $event The event * @return void */ public function shutdown(Event $event) { $controller = $event->subject(); $errors = []; array_walk_recursive($controller->viewVars, function (&$item) { // Execute queries so we can show the results in the toolbar. if ($item instanceof Query) { $item = $item->all(); } if ($item instanceof Closure || $item instanceof PDO || $item instanceof SimpleXmlElement) { $item = 'Unserializable object - ' . get_class($item); } if ($item instanceof Exception) { $item = sprintf('Unserializable object - %s. Error: %s in %s, line %s', get_class($item), $item->getMessage(), $item->getFile(), $item->getLine()); } return $item; }); foreach ($controller->viewVars as $k => $v) { // Get the validation errors for Entity if ($v instanceof EntityInterface) { $errors[$k] = $this->_getErrors($v); } elseif ($v instanceof Form) { $formError = $v->errors(); if (!empty($formError)) { $errors[$k] = $formError; } } } $this->_data = ['content' => $controller->viewVars, 'errors' => $errors]; }
public function setInheritableAttributesValues($values, $remplace = false) { $objectProperties = $this->getInheritableAttributes(); /* * transformation d'une structure array('attributeName'=>$value) * vers une structure du type * * array('attributeName'=>array( * 'value'=>$value * ) */ array_walk_recursive($values, function (&$value, $name) { $value = array('value' => $value); }); //on merge les valeurs avec la descriptions des attributs hérités if (!$remplace) { //si l'on n'écrase pas les valeurs, on merge les attributs hérités avec les valeurs courantes if ($currentValues = json_decode($this->getValue('data'), true)) { $this->inheritableAttributesValues = array_replace_recursive($currentValues, $objectProperties); } } else { //sinon on reset les valeurs en initialisant juste avec les propriété de l'attribut $this->inheritableAttributesValues = $objectProperties; } $this->inheritableAttributesValues = array_replace_recursive($this->inheritableAttributesValues, $values); $this->setValue('data', json_encode($this->inheritableAttributesValues, JSON_PRETTY_PRINT)); return $this; }
/** * Function processing raw HTTP request headers & body * and populates them to class variables. */ private function processRequest() { $this->request['resource'] = isset($_GET['RESTurl']) && !empty($_GET['RESTurl']) ? $_GET['RESTurl'] : 'index'; unset($_GET['RESTurl']); $this->request['method'] = strtolower($_SERVER['REQUEST_METHOD']); $this->request['headers'] = $this->getHeaders(); $this->request['format'] = isset($_GET['format']) ? trim($_GET['format']) : null; switch ($this->request['method']) { case 'get': $this->request['params'] = $_GET; break; case 'post': $this->request['params'] = array_merge($_POST, $_GET); break; case 'put': parse_str(file_get_contents('php://input'), $this->request['params']); break; case 'delete': $this->request['params'] = $_GET; break; default: break; } $this->request['content-type'] = $this->getResponseFormat($this->request['format']); if (!function_exists('trim_value')) { function trim_value(&$value) { $value = trim($value); } } array_walk_recursive($this->request, 'trim_value'); }
public function render($data) { $data = array_flip($data); $xml = new SimpleXMLElement($this->xmlroot); array_walk_recursive($data, array($xml, 'addChild')); return $xml->asXML(); }
/** * Need to do slightly less with attachments * * @return array */ public function get_data_for_transit() { $data = $this->get_data(); array_walk_recursive($data, array($this, 'object_to_array')); array_walk_recursive($data, array($this, 'trim_scalar')); return $data; }
/** * Render validation errors for the provided $element * * @param ElementInterface $element * @param array $attributes * @throws Exception\DomainException * @return string */ public function render(ElementInterface $element, array $attributes = array()) { $messages = $element->getMessages(); if (empty($messages)) { return ''; } if (!is_array($messages) && !$messages instanceof Traversable) { throw new Exception\DomainException(sprintf('%s expects that $element->getMessages() will return an array or Traversable; received "%s"', __METHOD__, is_object($messages) ? get_class($messages) : gettype($messages))); } // Prepare attributes for opening tag $attributes = array_merge($this->attributes, $attributes); $attributes = $this->createAttributesString($attributes); if (!empty($attributes)) { $attributes = ' ' . $attributes; } // Flatten message array $escapeHtml = $this->getEscapeHtmlHelper(); $messagesToPrint = array(); $self = $this; array_walk_recursive($messages, function ($item) use(&$messagesToPrint, $escapeHtml, $self) { if (null !== ($translator = $self->getTranslator())) { $item = $translator->translate($item, $self->getTranslatorTextDomain()); } $messagesToPrint[] = $escapeHtml($item); }); if (empty($messagesToPrint)) { return ''; } // Generate markup $markup = sprintf($this->getMessageOpenFormat(), $attributes); $markup .= implode($this->getMessageSeparatorString(), $messagesToPrint); $markup .= $this->getMessageCloseString(); return $markup; }
protected function addTemplateValues(&$data) { parent::addTemplateValues($data); $blocks = isset($this->data["value"]) ? $this->data["value"] : false; if (!$blocks && is_array($data["[DEFAULT]"])) { $blocks = $data["[DEFAULT]"]; } $buffer =& $data["[BLOCKS]"]; $buffer = ""; if ($blocks && is_array($blocks) && count($blocks) > 0) { $buffer = json_encode($blocks); if (strpos($buffer, '"') > -1) { // kill goddamn " which breaks esc_attr(json) array_walk_recursive($blocks, array("PeThemeFormElementLayout", "sanitize")); $buffer = json_encode($blocks); } $buffer = esc_attr($buffer); } $data["[ALLOWED]"] = empty($this->data["allowed"]) ? '' : esc_attr($this->data["allowed"]); $views = $this->data["views"]; $buffer =& $data["[MODULES]"]; $buffer = ""; if (!empty($views)) { foreach ($views as $s => $section) { foreach ($section as $idx => $view) { $cssClass = $view->cssClass(); $buffer .= sprintf('<div id="pe_module_%s" class="pe_module type_%s group_%s"><h3>%s<span class="help" title="%s">?</span></h3><div>%s</div></div>', $view->option(), $cssClass, $view->group(), $view->name(), $view->tooltip(), $s); } } } }
/** * Super Grid * @param $small size of small columns, accepts comma separated list **/ function get_awt_super_grid($small = false, $medium = false, $large = false, $group = "default", $addclass = array()) { // caching/tracking variables static $count = array(); static $columns = array(); static $class = array(); if (!isset($count[$group])) { //start count for this group $count[$group] = 0; //cache all columns in this group $columns[$group] = array("s" => explode(',', $small), "m" => explode(',', $medium), "l" => explode(',', $large)); //trim all column numbers for this group array_walk_recursive($columns[$group], function (&$a, $i) { $a = trim($a); }); if (!is_array($addclass)) { $class[$group] = explode(' ', $addclass); } } $classes = array_merge(array("columns"), $class[$group]); if ($small) { $index = $count[$group] % count($columns[$group]['s']); $classes[] = "small-{$columns[$group]['s'][$index]}"; } if ($medium) { $index = $count[$group] % count($columns[$group]['m']); $classes[] = "medium-{$columns[$group]['m'][$index]}"; } if ($large) { $index = $count[$group] % count($columns[$group]['l']); $classes[] = "large-{$columns[$group]['l'][$index]}"; } $count[$group]++; return implode(" ", $classes); }
/** * Generate ctag files for project library and Composer dependencies * * @param \Composer\Script\Event $event */ public static function ctag(Event $event) { $io = $event->getIO(); try { self::confirmDevMode($event); $ctagCommand = self::getCtagCommand(); $command = $ctagCommand::getCommand(); } catch (\Exception $e) { $io->write('PhpCtagger: ' . $e->getMessage()); return; } $io->write('Preparing to build tags file . . .'); self::$vendorDir = realpath($event->getComposer()->getConfig()->get('vendor-dir')); $tagsFile = self::getTagsDir() . '/tags'; self::deleteTagsFile($tagsFile); $autoloadNamespaces = (include self::$vendorDir . '/composer/autoload_namespaces.php'); // Flatten $paths array $paths = array(); array_walk_recursive($autoloadNamespaces, function ($p) use(&$paths) { $paths[] = $p; }); // In at least one instance, I've seen paths in the autoload_namespaces // file that don't exist. This removes them from the $paths array. $paths = array_filter($paths, function ($path) { return file_exists($path); }); $options = " -f {$tagsFile} \\\n -h '.php' \\\n -R \\\n --exclude='.git' \\\n --exclude='.svn' \\\n --totals=yes \\\n --tag-relative=yes \\\n --fields=+afkst \\\n --PHP-kinds=+cf \\\n --append=yes"; foreach ($paths as $path) { chdir($path); exec($command . $options . ' 2>&1', $output); $io->write($output, true); unset($output); } $io->write('Tagfile complete!'); }
/** * Replace data recursive * * @param array $data * @param array $bindData * @return array */ private function processData($data, $bindData) { array_walk_recursive($bindData, function (&$item) { $item = trim($item); }); $bindData = array_filter($bindData); foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = $this->processData($value, $bindData); } else { foreach ($bindData as $bindKey => $bindValue) { if (strpos($value, $bindKey) !== false) { if (is_string($bindValue)) { $data[$key] = str_replace($bindKey, $bindValue, $value); } else { $data[$key] = $bindValue; } $data['is_bind'] = true; } } } } return $data; }
private static function arrayHash(array $array) { array_walk_recursive($array, function (&$value) { $value = self::hash($value); }); return 'a' . md5(serialize($array)); }
/** * @param string $name Image name * @param string $module Module name * @param string|array $descriptor Path to image file, or array structure containing paths * @param string $basePath Directory to which paths in descriptor refer * @param array $variants * @throws InvalidArgumentException */ public function __construct($name, $module, $descriptor, $basePath, $variants) { $this->name = $name; $this->module = $module; $this->descriptor = $descriptor; $this->basePath = $basePath; $this->variants = $variants; // Expand shorthands: // array( "en,de,fr" => "foo.svg" ) // → array( "en" => "foo.svg", "de" => "foo.svg", "fr" => "foo.svg" ) if (is_array($this->descriptor) && isset($this->descriptor['lang'])) { foreach (array_keys($this->descriptor['lang']) as $langList) { if (strpos($langList, ',') !== false) { $this->descriptor['lang'] += array_fill_keys(explode(',', $langList), $this->descriptor['lang'][$langList]); unset($this->descriptor['lang'][$langList]); } } } // Ensure that all files have common extension. $extensions = array(); $descriptor = (array) $descriptor; array_walk_recursive($descriptor, function ($path) use(&$extensions) { $extensions[] = pathinfo($path, PATHINFO_EXTENSION); }); $extensions = array_unique($extensions); if (count($extensions) !== 1) { throw new InvalidArgumentException("File type for different image files of '{$name}' not the same"); } $ext = $extensions[0]; if (!isset(self::$fileTypes[$ext])) { throw new InvalidArgumentException("Invalid file type for image files of '{$name}' (valid: svg, png, gif, jpg)"); } $this->extension = $ext; }
/** * Cleans an entire array recursively * from having string injection * * @param array $array - The original array * @return array - The escaped array */ public static function ClearArray($array) { array_walk_recursive($array, function (&$item) { $item = String::ClearString($item); }); return $array; }
/** * @param object $object object instance to traverse * * @throws \InvalidArgumentException * * @return array */ public function createArray($object) { if (!is_object($object)) { throw new \InvalidArgumentException('The first param should be a object.'); } $array = []; if ($object instanceof Object2ArrayInterface) { $array = $object->__toArray(); array_walk_recursive($array, function (&$item) { if (is_object($item)) { $item = $this->createArray($item); } }); } else { $reflClass = new \ReflectionClass($object); foreach (Utils::getClassProperties($reflClass) as $property) { if ($this->context->getReader()->isReadable($object, $property->getName())) { $value = $this->context->getReader()->getValue($object, $property->getName()); $types = $types = Utils::getPropertyTypes($property); $value = $this->parseValue($value, $types, $property, $object); if ($value === null && $this->context->isIgnoreNulls()) { continue; } $transformedName = $this->context->getNamingStrategy()->transformName($property->getName()); $array[$transformedName] = $value; } } } return $array; }
/** * Load the list of drivers. * * @return array */ public static function getDrivers() { if (isset(self::$_driverlist)) { return self::$_driverlist; } $fi = new FilesystemIterator(__DIR__ . '/Autoconfig/Driver'); $class_prefix = __CLASS__ . '_Driver_'; $drivers = array(); foreach ($fi as $val) { if ($val->isFile()) { $cname = $class_prefix . $val->getBasename('.php'); if (class_exists($cname)) { $ob = new $cname(); if ($ob instanceof Horde_Mail_Autoconfig_Driver) { $drivers[$ob->priority][] = $ob; } } } } ksort($drivers, SORT_NUMERIC); $flatten = array(); array_walk_recursive($drivers, function ($a) use(&$flatten) { $flatten[] = $a; }); self::$_driverlist = $flatten; return $flatten; }
public function setValue($values) { if (is_scalar($values) || $values === NULL) { $values = (array) $values; } elseif (!is_array($values)) { throw new Nette\InvalidArgumentException(sprintf("Value must be array or NULL, %s given in field '%s'.", gettype($values), $this->name)); } $flip = array(); foreach ($values as $value) { if (!is_scalar($value) && !method_exists($value, '__toString')) { throw new Nette\InvalidArgumentException(sprintf("Values must be scalar, %s given in field '%s'.", gettype($value), $this->name)); } $flip[(string) $value] = TRUE; } $values = array_keys($flip); $items = $this->items; $nestedKeys = array(); array_walk_recursive($items, function ($value, $key) use(&$nestedKeys) { $nestedKeys[] = $key; }); if ($diff = array_diff($values, $nestedKeys)) { $range = Nette\Utils\Strings::truncate(implode(', ', array_map(function ($s) { return var_export($s, TRUE); }, $nestedKeys)), 70, '...'); $vals = (count($diff) > 1 ? 's' : '') . " '" . implode("', '", $diff) . "'"; throw new Nette\InvalidArgumentException("Value{$vals} are out of allowed range [{$range}] in field '{$this->name}'."); } $this->value = $values; return $this; }
/** * Computes the output for the given data table * * @param DataTable $table * @return string */ protected function renderTable($table) { if (is_array($table)) { $array = $table; if (self::shouldWrapArrayBeforeRendering($array, $wrapSingleValues = true)) { $array = array($array); } foreach ($array as $key => $tab) { if ($tab instanceof DataTable\Map || $tab instanceof DataTable || $tab instanceof DataTable\Simple) { $array[$key] = $this->convertDataTableToArray($tab); if (!is_array($array[$key])) { $array[$key] = array('value' => $array[$key]); } } } } else { $array = $this->convertDataTableToArray($table); } if (!is_array($array)) { $array = array('value' => $array); } // decode all entities $callback = function (&$value, $key) { if (is_string($value)) { $value = html_entity_decode($value, ENT_QUOTES, "UTF-8"); } }; array_walk_recursive($array, $callback); // silence "Warning: json_encode(): Invalid UTF-8 sequence in argument" $str = @json_encode($array); return $str; }
private function TicketList() { if ($this->is_owner === true) { $all_users = $this->get_all_users(); foreach ($all_users as $user) { if ($user != $this->userName) { $files_ticket[] = glob('../conf/users/' . $user . '/support*.json'); } } if (empty($files_ticket)) { $files_ticket = []; } //converti un tableau multidimensionnel en un tableau unidimensionnel. // note : le caractère & fait pointer le contenu sur la variable, pour conserver les data // note : fonctions anonymes prend comme param function ($value, $key) $all_files_tickets = []; $bool = array_walk_recursive($files_ticket, function ($value) use(&$all_files_tickets) { $all_files_tickets[] = $value; }); return $all_files_tickets; } else { $files_tickets = glob('../conf/users/' . $this->userName . '/support*.json'); return $files_tickets; } }
function array_walk_recursive(&$input, $funcname) { if (!is_callable($funcname)) { if (is_array($funcname)) { $funcname = $funcname[0] . '::' . $funcname[1]; } user_error('array_walk_recursive() Not a valid callback ' . $user_func, E_USER_WARNING); return; } if (!is_array($input)) { user_error('array_walk_recursive() The argument should be an array', E_USER_WARNING); return; } $args = func_get_args(); foreach ($input as $key => $item) { if (is_array($item)) { array_walk_recursive($item, $funcname, $args); $input[$key] = $item; } else { $args[0] =& $item; $args[1] =& $key; call_user_func_array($funcname, $args); $input[$key] = $item; } } }
protected function _configureViaDSN($dsn) { $dsnVars = array(); if (strpos($dsn, '=') === false) { throw new Zend_Tool_Project_Provider_Exception('At least one name value pair is expected, typcially ' . 'in the format of "adapter=Mysqli&username=uname&password=mypass&dbname=mydb"'); } parse_str($dsn, $dsnVars); // parse_str suffers when magic_quotes is enabled if (get_magic_quotes_gpc()) { array_walk_recursive($dsnVars, array($this, '_cleanMagicQuotesInValues')); } $dbConfigValues = array('resources' => array('db' => null)); if (isset($dsnVars['adapter'])) { $dbConfigValues['resources']['db']['adapter'] = $dsnVars['adapter']; unset($dsnVars['adapter']); } $dbConfigValues['resources']['db']['params'] = $dsnVars; $isPretend = $this->_registry->getRequest()->isPretend(); // get the config resource $applicationConfig = $this->_loadedProfile->search('ApplicationConfigFile'); $applicationConfig->addItem($dbConfigValues, $this->_sectionName, null); $response = $this->_registry->getResponse(); if ($isPretend) { $response->appendContent('A db configuration for the ' . $this->_sectionName . ' section would be written to the application config file with the following contents: '); $response->appendContent($applicationConfig->getContents()); } else { $applicationConfig->create(); $response->appendContent('A db configuration for the ' . $this->_sectionName . ' section has been written to the application config file.'); } }
function sy_log($file, $data, $lines = 300) { static $logs; if (empty($logs)) { $logs = array(); } if (!Simplify::config()) { return; } $file = APP_DIR . '/logs/' . $file . '.log'; $a = @file($file, FILE_IGNORE_NEW_LINES); if ($lines && count($a) > $lines) { $a = array_slice($a, count($a) - $lines); } if (!isset($logs[$file])) { $logs[$file] = true; $a[] = "-> started " . date('Y-m-d H:i:s'); } $output = date('Y-m-d H:i:s') . ' -> '; if (!empty($data)) { if (is_string($data)) { $output .= trim($data); } elseif ($data instanceof \Simplify\DictionaryInterface) { $data = $data->getAll(); array_walk_recursive($data, 'sy_array_map'); $output .= var_export($data, true); } else { $output .= var_export($data, true); } } $a[] = $output; file_put_contents($file, implode("\n", $a)); }