本文整理汇总了PHP中FrmAppHelper::array_flatten方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmAppHelper::array_flatten方法的具体用法?PHP FrmAppHelper::array_flatten怎么用?PHP FrmAppHelper::array_flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmAppHelper
的用法示例。
在下文中一共展示了FrmAppHelper::array_flatten方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: entry_array_to_string
public static function entry_array_to_string($values)
{
$content = '';
foreach ($values['item_meta'] as $val) {
if ($content != '') {
$content .= "\n\n";
}
if (is_array($val)) {
$val = FrmAppHelper::array_flatten($val);
$val = implode(',', $val);
}
$content .= $val;
}
return $content;
}
示例2: replace_single_shortcode
public static function replace_single_shortcode($shortcodes, $short_key, $tag, $entry, $display, $args, &$content)
{
global $post;
$conditional = preg_match('/^\\[if/s', $shortcodes[0][$short_key]) ? true : false;
$foreach = preg_match('/^\\[foreach/s', $shortcodes[0][$short_key]) ? true : false;
$atts = shortcode_parse_atts($shortcodes[3][$short_key]);
$tag = FrmFieldsHelper::get_shortcode_tag($shortcodes, $short_key, compact('conditional', 'foreach'));
if (strpos($tag, '-')) {
$switch_tags = array('post-id', 'created-at', 'updated-at', 'created-by', 'updated-by', 'parent-id');
if (in_array($tag, $switch_tags)) {
$tag = str_replace('-', '_', $tag);
}
unset($switch_tags);
}
$tags = array('event_date', 'entry_count', 'detaillink', 'editlink', 'deletelink', 'created_at', 'updated_at', 'created_by', 'updated_by', 'evenodd', 'post_id', 'parent_id', 'id');
if (in_array($tag, $tags)) {
$args['entry'] = $entry;
$args['tag'] = $tag;
$args['conditional'] = $conditional;
$function = 'do_shortcode_' . $tag;
self::$function($content, $atts, $shortcodes, $short_key, $args, $display);
return;
}
$field = FrmField::getOne($tag);
if (!$field) {
return;
}
if (!$foreach && !$conditional && isset($atts['show']) && ($atts['show'] == 'field_label' || $atts['show'] == 'description')) {
// get the field label or description and return before any other checking
$replace_with = $atts['show'] == 'field_label' ? $field->name : $field->description;
$content = str_replace($shortcodes[0][$short_key], $replace_with, $content);
return;
}
$sep = isset($atts['sep']) ? $atts['sep'] : ', ';
if ($field->form_id == $entry->form_id) {
$replace_with = FrmProEntryMetaHelper::get_post_or_meta_value($entry, $field, $atts);
} else {
// get entry ids linked through repeat field or embeded form
$child_entries = FrmProEntry::get_sub_entries($entry->id, true);
$replace_with = FrmProEntryMetaHelper::get_sub_meta_values($child_entries, $field, $atts);
$replace_with = FrmAppHelper::array_flatten($replace_with);
}
$atts['entry_id'] = $entry->id;
$atts['entry_key'] = $entry->item_key;
$atts['post_id'] = $entry->post_id;
$replace_with = apply_filters('frmpro_fields_replace_shortcodes', $replace_with, $tag, $atts, $field);
self::get_file_from_atts($atts, $field, $replace_with);
if (isset($atts['show']) && $atts['show'] == 'count') {
$replace_with = is_array($replace_with) ? count($replace_with) : !empty($replace_with);
} else {
if (is_array($replace_with) && !$foreach) {
$replace_with = FrmAppHelper::array_flatten($replace_with);
$replace_with = implode($sep, $replace_with);
}
}
if ($foreach) {
$atts['short_key'] = $shortcodes[0][$short_key];
$args['display'] = $display;
self::check_conditional_shortcode($content, $replace_with, $atts, $tag, 'foreach', $args);
} else {
if ($conditional) {
$atts['short_key'] = $shortcodes[0][$short_key];
self::check_conditional_shortcode($content, $replace_with, $atts, $tag, 'if', array('field' => $field));
} else {
if (empty($replace_with) && $replace_with != '0') {
$replace_with = '';
if ($field->type == 'number') {
$replace_with = '0';
}
} else {
$replace_with = FrmFieldsHelper::get_display_value($replace_with, $field, $atts);
}
self::trigger_shortcode_atts($atts, $display, $args, $replace_with);
$content = str_replace($shortcodes[0][$short_key], $replace_with, $content);
}
}
}
示例3: get_var
public static function get_var($table, $where = array(), $field = 'id', $args = array(), $limit = '', $type = 'var')
{
$group = '';
self::get_group_and_table_name($table, $group);
self::convert_options_to_array($args, '', $limit);
$query = 'SELECT ' . $field . ' FROM ' . $table;
if (is_array($where) || empty($where)) {
// only separate into array values and query string if is array
self::get_where_clause_and_values($where);
global $wpdb;
$query = $wpdb->prepare($query . $where['where'] . ' ' . implode(' ', $args), $where['values']);
} else {
/**
* Allow the $where to be prepared before we recieve it here.
* This is a fallback for reverse compatability, but is not recommended
*/
_deprecated_argument('where', '2.0', __('Use the query in an array format so it can be properly prepared.', 'formidable'));
$query .= $where . ' ' . implode(' ', $args);
}
$cache_key = str_replace(array(' ', ','), '_', trim(implode('_', FrmAppHelper::array_flatten($where)) . implode('_', $args) . $field . '_' . $type, ' WHERE'));
$results = FrmAppHelper::check_cache($cache_key, $group, $query, 'get_' . $type);
return $results;
}
示例4: add_repeating_value_to_entry
public static function add_repeating_value_to_entry($field, &$entry)
{
// If field is in a repeating section
if ($entry->form_id != $field->form_id) {
// get entry ids linked through repeat field or embeded form
$child_entries = FrmProEntry::get_sub_entries($entry->id, true);
$val = FrmProEntryMetaHelper::get_sub_meta_values($child_entries, $field);
if (!empty($val)) {
//Flatten multi-dimensional arrays
if (is_array($val)) {
$val = FrmAppHelper::array_flatten($val);
}
$entry->metas[$field->id] = $val;
}
} else {
$val = '';
FrmProEntriesHelper::get_dynamic_list_values($field, $entry, $val);
$entry->metas[$field->id] = $val;
}
}
示例5: print_csv_row
private static function print_csv_row($rows)
{
$col_count = count($rows);
$this_col = 0;
foreach ($rows as $k => $row) {
$this_col++;
if (!isset(self::$headings[$k])) {
// this column has been removed from the csv, so skip it
continue;
}
if (is_array($row)) {
// implode the repeated field values
$row = implode(self::$separator, FrmAppHelper::array_flatten($row, 'reset'));
}
$val = self::encode_value($row);
if (self::$line_break != 'return') {
$val = str_replace(array("\r\n", "\r", "\n"), self::$line_break, $val);
}
echo '"' . $val . '"';
if ($this_col != $col_count) {
echo self::$column_separator;
}
unset($k, $row);
}
echo "\n";
}
示例6: flatten_multi_file_upload
/**
* Flatten multi-dimensional array for multi-file upload fields
* @since 2.0.9
*/
public static function flatten_multi_file_upload($field, &$val)
{
if ($field->type == 'file' && FrmField::is_option_true($field, 'multiple')) {
$val = FrmAppHelper::array_flatten($val);
}
}
示例7: print_csv_row
private static function print_csv_row($rows)
{
$sep = '';
foreach (self::$headings as $k => $heading) {
$row = isset($rows[$k]) ? $rows[$k] : '';
if (is_array($row)) {
// implode the repeated field values
$row = implode(self::$separator, FrmAppHelper::array_flatten($row, 'reset'));
}
$val = self::encode_value($row);
if (self::$line_break != 'return') {
$val = str_replace(array("\r\n", "\r", "\n"), self::$line_break, $val);
}
echo $sep . '"' . $val . '"';
$sep = self::$column_separator;
unset($k, $row);
}
echo "\n";
}
示例8: get_associative_array_results
/**
* Get the associative array results for the given columns, table, and where query
*
* @since 2.02.05
* @param string $columns
* @param string $table
* @param array $where
* @return mixed
*/
public static function get_associative_array_results($columns, $table, $where)
{
$group = '';
self::get_group_and_table_name($table, $group);
$query = self::generate_query_string_from_pieces($columns, $table, $where);
$cache_key = str_replace(array(' ', ','), '_', trim(implode('_', FrmAppHelper::array_flatten($where)) . $columns . '_results_ARRAY_A', ' WHERE'));
$results = FrmAppHelper::check_cache($cache_key, $group, $query, 'get_associative_results');
return $results;
}