小编kev*_*eda的帖子

使用 phpspreadsheet 循环返回行

我有一张 Excel 工作表,我只想循环浏览一行。现在我得到了这个:

$reader->setReadDataOnly(TRUE);
$spreadsheet = $reader->load("KEVIN Call Monkey ALLE BEDRIJVEN 29-10-18 Export_bedrijven_20181030_105432.xlsx");

$worksheet = $spreadsheet->getActiveSheet();


foreach ($worksheet->getRowIterator() as $row) {
    $cellIterator = $row->getCellIterator();
    $cellIterator->setIterateOnlyExistingCells(FALSE); // This loops through all cells,
                                                       //    even if a cell value is not set.
                                                       // By default, only cells that have a value
                                                       //    set will be iterated.
    foreach ($cellIterator as $cell) {
        echo 
             $cell->getValue();

    }

}
Run Code Online (Sandbox Code Playgroud)

这将返回每一行。我只想显示一行。在本例中为“J”行。

更新的代码:

require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\IReader;
use \PhpOffice\PhpSpreadsheet\IOFactory;

$inputFileName  =  'KEVIN Call Monkey …
Run Code Online (Sandbox Code Playgroud)

php excel

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

Jquery切换.css

我有这个运行良好的jquery代码.

$(window).load(function() {

    $('.menuBtn').click(function(e) {
        e.preventDefault();
        (this.classList.contains('is-active') === true) ? this.classList.remove('is-active'): this.classList.add('is-active');
        $('nav').slideToggle();

        $('.headerBarm').toggleClass('fixed-position');
        $('nav').toggleClass('fixed-position');
        $('.headerBar').toggleClass('fixed-position');


        $('body').css({
            'height': '100%',
            'overflow': 'hidden'
        });

    });

});
Run Code Online (Sandbox Code Playgroud)

最近我添加了最后一行.

$('body').css({
                'height': '100%',
                'overflow': 'hidden'
            });
Run Code Online (Sandbox Code Playgroud)

当我点击按钮时,上面的CSS被添加.

我的问题是,当我再次点击它时它不会改变回来.这可以与切换类型一起工作吗?

css jquery

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

获取 Woocommerce 中的订单商品名称

所以我有一个变量,如果我使用var_dump该变量,我会得到一个大数组。我正在尝试获得以下内容:

["name"]=> string(26) "Online marketing Duitsland" 
Run Code Online (Sandbox Code Playgroud)

整个数组结果如下所示:

array(1) { 
  [33]=> object(WC_Order_Item_Product)#9730 (11) { 
    ["extra_data":protected]=> array(9) { 
      ["product_id"]=> int(0) 
      ["variation_id"]=> int(0) 
      ["quantity"]=> int(1) 
      ["tax_class"]=> string(0) "" 
      ["subtotal"]=> int(0) 
      ["subtotal_tax"]=> int(0) 
      ["total"]=> int(0) 
      ["total_tax"]=> int(0) 
      ["taxes"]=> array(2) { 
        ["subtotal"]=> array(0) { } 
        ["total"]=> array(0) { } 
      } 
    } 
    ["data":protected]=> array(11) { 
      ["order_id"]=> int(12291) 
      ["name"]=> string(26) "Online marketing Duitsland" 
      ["product_id"]=> int(11927) 
      ["variation_id"]=> int(0) 
      ["quantity"]=> int(1) 
      ["tax_class"]=> string(0) "" 
      ["subtotal"]=> string(4) "3700" 
      ["subtotal_tax"]=> string(1) "0" 
      ["total"]=> string(4) "3700" 
      ["total_tax"]=> string(1) "0" 
      ["taxes"]=> …
Run Code Online (Sandbox Code Playgroud)

php orders woocommerce

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

自动将对象添加到数组

我有一个名为male的类,看起来像这样:

class Male {
    public $gender; 
    public $age;
    public $love;
    public $looks;
    public $humor;

    public function __construct ($age , $love , $looks , $humor) {
        $this->gender = 'Male'; 
        $this->age = $age;
        $this->love = $love;
        $this->looks = $looks;
        $this->humor = $humor;
    }
}
Run Code Online (Sandbox Code Playgroud)

每次有这样一个类的新实例:

$hans = new Male(12 , 45 , 76 , 40);
Run Code Online (Sandbox Code Playgroud)

我希望将该实例自动添加到数组中.现在我这样做:

$maleArray = array($hans);
Run Code Online (Sandbox Code Playgroud)

现在我必须自己做.所以假设我创建了我的类的另一个实例,然后我必须将它添加到maleArray变量中.我想这会自动发生.

例如,如果我创建了一个名为herman的实例,那么新版本的maleArray应该是:

 $maleArray = array($hans, $herman);
Run Code Online (Sandbox Code Playgroud)

有没有办法实现这个目标?

php

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

标签 统计

php ×3

css ×1

excel ×1

jquery ×1

orders ×1

woocommerce ×1