小编Rez*_*eza的帖子

将文件和目录添加到特定的子目录

我使用以下脚本将我的目录(在本例中My_Theme)的文件移动到zip存档wordpress.zip.

define('CLIENT_PATH', $_SERVER['DOCUMENT_ROOT'] . '/wp_theme/clients_templates/' . str_replace(' ', '_', $_POST['title']));
$zip = new ZipArchive;
$zip->open('wordpress.zip', ZipArchive::CREATE);
foreach (glob(CLIENT_PATH . "/*.*") as $file) {
    echo $file . '<br>';
   $zip->addFile($file);
}
$zip->close();
Run Code Online (Sandbox Code Playgroud)

现在当我下载并解压缩该文件时,我的文件夹结构如下所示:

在此输入图像描述

我想要的是将目录移动My_Themewordpress/wp-content/themes/

结果将是:( wordpress/wp-content/themes/My_Theme包括其中的所有文件和子目录)

我怎样才能做到这一点?

php zip ziparchive

7
推荐指数
1
解决办法
142
查看次数

多维数组:如何获取特定键的所有值?

我有一个多维数组,其中包括ID和URL.我想只输出网址.

$abstract_details = array(
                        array(
                            'id' => 68769782222,
                            'url' => 'http://yourclick.ch'
                        ),
                        array(
                            'id' => 111,
                            'url' => 'http://google.com'
                        )
                    );

foreach ($abstract_details as $abstract_detail) {
    foreach ($abstract_detail as $get_abstract_detail) {
        $result .= $get_abstract_detail . '<br>';
    }
}
Run Code Online (Sandbox Code Playgroud)

当我运行我的代码时,我得到了两个信息.如何控制我想要展示的内容?

php arrays foreach multidimensional-array

4
推荐指数
2
解决办法
5554
查看次数

获取所有选中的复选框的列表

我想弄清楚哪些复选框被选中,所以我尝试了以下代码:

$('.feature input[type="checkbox"').serialize();
Run Code Online (Sandbox Code Playgroud)

这是我的 HTML 的样子:

<div class="feature">
  <h2>Features</h2>
  <label><input class="custom_css" checked="" type="checkbox" name="feature[]"> Custom CSS (style.css)</label>
  <label><input class="custom_js" checked="" type="checkbox" name="feature[]"> Custom Javascript (script.js)</label>
  <label><input class="modernizr" type="checkbox" name="feature[]"> Modernizr</label>
  <label><input class="google_maps" type="checkbox" name="feature[]"> Google Maps</label>
  <label><input class="custom_api" type="checkbox" name="feature[]"> Custom API</label>
  <label><input class="font_awesome" type="checkbox" name="feature[]"> Font Awesome</label>
</div>
Run Code Online (Sandbox Code Playgroud)

这是我得到的输出:

数组(1) { ["var_sent_via_ajax"]=> 字符串(67) "feature%5B%5D=on&feature%5B%5D=on&feature%5B%5D=on&feature%5B%5D=on" }

现在我怎样才能知道其中哪些已经被检查过呢?%5B%5D符号是什么意思?

javascript checkbox jquery

3
推荐指数
1
解决办法
2万
查看次数

创建一个"动态高度"的框

我正在寻找一种方法来创建一个看起来像这个图形的CSS的div:

在此输入图像描述

右下方不是白色而是透明的.

怎么可能呢?

html css jquery-ui

2
推荐指数
1
解决办法
83
查看次数

字符串中的某些字符无法替换

我想改变这个字符串

测试 - GGAökologieGeschäftsführer.PDF

进入这个:

测试_-_ gga_oekologie_geschaaeftsfuuehrer.pdf

这是我尝试过的:

$characters = array('ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', ' ');
$converted_characters = array('ae', 'oe', 'ue', 'AE', 'OE', 'UE', '_');
$string = 'Test - GGA o?kologie Gescha?ftsfu?hrer.PDF';

echo strtolower(str_replace($characters, $converted_characters , $string));
Run Code Online (Sandbox Code Playgroud)

上面的代码返回:test _-_gga_ökologie_geschäftsführer.pdf

如您所见,字符串仍包含字符öä.

我的代码出了什么问题?

php

2
推荐指数
2
解决办法
95
查看次数

Split a text into two lines

Is there a way to force a part of a text to display on a new line with CSS?

So when the HTML looks like this:

<p>Hello, my name is John.</p>
Run Code Online (Sandbox Code Playgroud)

The result will be:

Hello,

my name is John.

The HTML is generated dynamically, so I cannot change it.

css

0
推荐指数
1
解决办法
2万
查看次数

随机运行函数

我有一个包含一些函数的数组,它看起来像这样:

var all_questions = [
    show_question(1, 1),
    show_question(2, 1),
    show_question(3, 1),
];
Run Code Online (Sandbox Code Playgroud)

我想随机将这些函数运行到该数组中.我怎样才能做到这一点?

javascript arrays jquery

-5
推荐指数
1
解决办法
121
查看次数