I have a database where i have multiple "shoutouts". Each of these can have multiple hashtags.
In the database it looks like this:
a:2:{i:0;s:6:"#hello";i:1;s:6:"#world";}
I am trying to create a function where I find each shoutout that has a specific keyword, for example all shoutouts that have a hashtag #world
I want to go trough all shoutouts and check if they have the keyword in the array.
public function shoutoutSpecific($hashtag) {
$hashtag = '#' . $hashtag;
$shoutoutsIn = Shoutout::get();
foreach($shoutoutsIn as $shoutout) {
$hashtags = unserialize($shoutout->hashtag);
//add to a new object 'shoutouts' if it has the keyword
}
return view('shoutout', compact('shoutouts'));
}
I don't know what to do with the data I have unserialized from the database to check if the array contains #world
. The serialized data is stored as shown above.
How do I check if the data I unserialized have #world
in it?
All help much appreciated!