Home » Php » string – How do I use array for php strtok?

string – How do I use array for php strtok?

Posted by: admin February 25, 2020 Leave a comment

Questions:

In my code example above, I split a string with strtok. But another zone of the page;

// echo $tok[1]; ...... echo $tok[9];   

I want to pull data like … But I couldn’t do it. How can I do it?

edit: Actually, what I want to do is this: I want to be able to pull all the data on a column in the database and print them one by one.

$query = $db->query("SELECT * FROM submenu WHERE sublink IS NOT null", PDO::FETCH_ASSOC);
if ( $query->rowCount() )
{
    foreach( $query as $row ){
        $deger = $row['sublink'];

        $tok = strtok($deger, ".");

        while ($tok !== false) {
            echo "$tok<br />";
            $tok = strtok(".php");
        }

    }
}
How to&Answers: