2016-05-06 90 views
-1

這似乎看起來像我的一切都很好,但我不知道爲什麼它給了我這種錯誤:請幫我WordPress的陣列不起作用

Parse error: syntax error, unexpected '[' in /home/sites/xyz.com/public_html/wp-content/themes/abc/single-products.php on line 330

======= ======

Parse error: syntax error, unexpected '[' in /home/sites/xyz.com/public_html/wp-content/themes/abc/single-products.php on line 331

這裏是我的代碼:

<?php 
$exclude = ['diffusion','twice-loved','antique-vintage']; 
$tax_slugs = []; 
foreach ($tax as $value) { 
    array_push($tax_slugs, $value->slug); 
} 
$intersect = count(array_intersect($exclude, $tax_slugs)); 
//if($tax[0]->slug != 'diffusion'): 
if($intersect === 0): 
?> 
+1

'$ exclude'應該是一個數組嗎?你讀過如何在PHP中創建一個數組? – Dan

回答