-3
I need to mount an array by pulling the Slug from my table, example:
$array = array (
'esportes',
'mundo',
'estado'
);
I tried so:
$slug = $con->prepare("SELECT slug FROM categorias");
$slug->execute();
$array = array (
foreach ( $slug as $row ) {
echo "'.$row['slug'].',";
}
);
I need to use this array to make a friendly url that looks like this:
$url = $_GET['url'];
$sep = array_filter ( explode ( "/", $url ) );
Here I need the array:
if ( isset ( $sep[0] ) && $sep[0] in_array ( $sep[0], $array ) ) {
$Categoria = new Categoria;
$Categoria->GetCategoria;
}
Does anyone know any solution?
If you use PDO: https://www.php.net/manual/en/pdostatement.fetchall.php; otherwise, https://www.php.net/manual/en/mysqli-stmt.fetch.php
– Valdeir Psr
@Valdeir Par using the first option I can do that 'if'?
– ProgramadorAprendiz
His last
if..isset
? It depends on your data structure and data return.– Valdeir Psr
@Valdeir Par the return would be the array
– ProgramadorAprendiz