小编Mic*_*oos的帖子

使用PHP检查逗号分隔字符串中是否存在值

我需要检查我的id是否以逗号分隔的字符串存在.

我的字符串保存"1,2,3,4,10"在数据库中.

我试过了

$HiddenProducts = array($sqlvalue);

if (in_array(2, $HiddenProducts)) {
  echo "Available";
} else {
  echo "Not available";
}
Run Code Online (Sandbox Code Playgroud)

它不起作用.任何解决方案请......

php

10
推荐指数
1
解决办法
4万
查看次数

如何在使用JavaScript创建的SVG元素上设置viewBox?

当我在DOM中已经存在的SVG元素上使用setAttribute('viewBox')时,它被正确设置(使用大写'b').

当我在JavaScript中创建一个SVG元素并在那里添加'viewBox'属性...它以全小写字母结尾在DOM中.

为什么是这样?

document.querySelector('#circle svg').setAttribute('viewBox', '190 190 20 20');

let svg = document.createElement('svg'),
  circle = document.createElement('circle');

circle.setAttribute('cx', 200);
circle.setAttribute('cy', 200);
circle.setAttribute('r', 10);
svg.setAttribute('viewBox', '190 190 20 20');
svg.appendChild(circle);
document.body.appendChild(svg);

// document.querySelector('#circleGenerated svg').setAttribute('viewBox', '190 190 20 20');
Run Code Online (Sandbox Code Playgroud)
svg {
  border: 2px dashed #666;
  width: 200px;
  height: 200px;
}
Run Code Online (Sandbox Code Playgroud)
<p>Existing svg with dynamically added viewBox attribute:</p>
<div id="circle">
  <svg>
    <circle cx="200" cy="200" r="10" id="center-point" fill="#bbb" />
  </svg>
</div>

<p>Generated svg with dynamically added viewBox attribute:</p>
Run Code Online (Sandbox Code Playgroud)

html javascript svg

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

标签 统计

html ×1

javascript ×1

php ×1

svg ×1