array_map 对数组进行遍历处理

<?php
$spu =["QTHQO0021","OTXCY9249","QTHQO0012","QTHQO0011","3CHQO0002","QTHQO0004","QTHQO0001"];
$spu =array_map(function($spu){return '\''.$spu.'\'';}, $spu_arr);
var_dump($spu);

array(7) {
  [0]=>
  string(11) "'QTHQO0021'"
  [1]=>
  string(11) "'OTXCY9249'"
  [2]=>
  string(11) "'QTHQO0012'"
  [3]=>
  string(11) "'QTHQO0011'"
  [4]=>
  string(11) "'3CHQO0002'"
  [5]=>
  string(11) "'QTHQO0004'"
  [6]=>
  string(11) "'QTHQO0001'"
}

 

posted on 2021-03-31 16:44  kevin_yang123  阅读(204)  评论(0编辑  收藏  举报