L
L
ligisayan2016-02-08 15:26:41
PHP
ligisayan, 2016-02-08 15:26:41

How to find out: is there a piece of the phrase in the link?

Hello! There is an online store on wordpress. The $cat_link variable can contain links like

http://domen/product-category/name-category/yamaha-lodki/

How to detect if a view category label is present in any part:
$cat_slug = yamaha-lodki;
so that you can walk through the condition:
if($cat_link==$cat_slug) {..}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
krypt3r, 2016-02-08
@ligisayan

if (strpos($cat_link, $cat_slug) !== false) {
    // найдено, что-то сделать
}

A
Alexander Aksentiev, 2016-02-08
@Sanasol

strpos

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question