duanben4771 2018-12-03 16:25
浏览 36

需要PHP自定义功能代码WP All Import - Wordpress

I had a CSV with products to be imported to Woocommerce Via WP All Import Plugin.

The CSV had extra category text that needed to be removed before the hyphen ( - )

So the WP All Import team told me to use the following code in the function editor:

function my_cat( $subcat )
{
$subcat = explode("-", $subcat);

$new_sub = array_key_exists(1, $subcat)?$subcat[1] : $subcat[0];

return trim($new_sub);
}

Then call it with the snippet below:

[my_cat({prodlinelangname[1]})]

This worked fine but the problem now is that i have a new CSV that needs to remove text both before and after hyphens.

For example;

TEXT1 - TEXT2 - TEXT3

I need to remove everything from the CSV field except TEXT2.

What code can i use?

Cheers, Victor

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 vue3+element-plus页面崩溃
    • ¥15 像这种代码要怎么跑起来?
    • ¥15 怎么改成循环输入删除(语言-c语言)
    • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
    • ¥15 pyqt5tools安装失败
    • ¥15 mmdetection
    • ¥15 nginx代理报502的错误
    • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
    • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
    • ¥100 描述一下元器件的基本功能,pcba板的基本原理