joe_ma Posted October 18, 2016 Share Posted October 18, 2016 (edited) Hi How can I seperate pages whose title contains a certain string from an array of pages? So with $results = $pages->find("template=template_name"); I get an array of all the pages. Now I should like to extract only the pages that contain the string 'Nr. 7' in the title. How can I do this? Is there a direct way with strpos()? EDIT: Found the solution: $tickets = array(); foreach ($results as $result){ if (strpos($result->title, 'Nr. 7') !== false){ $tickets[] = $result; } } Edited October 18, 2016 by joe_ma Problem solved Link to comment Share on other sites More sharing options...
fbg13 Posted October 18, 2016 Share Posted October 18, 2016 $pages->find("template=template_name, name*=whatever"); This should do it https://processwire.com/api/selectors/#operators 3 Link to comment Share on other sites More sharing options...
joe_ma Posted October 18, 2016 Author Share Posted October 18, 2016 Oh, thanks very much! Could have known this from the search template … Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now