I'm trying to do the equivalent of a mysql like for php mongo; finding any link in my articles collection thats starts with www.foo.com/{category}. I can execute it fine in the shell but the php driver seems to not be interpolating my command correctly. And the mongo regex lacks thorough documentation. Heres my code.
$cats = ['news', 'life', 'humor'];
foreach($cats as $cat){
$category = 'www.foo.com/' . $cat;
$articles = db()->articles->find(['link' => array('$regex'=>new MongoRegex("/^$category/"))]);
}
it returns articles but the links do not match.