I want to get the strings after each :
and before each
from the following:
När:Sent lördag kväll och natt till söndag
Var:Främst norra Jämtland
Intensitet:Väst ca 21 m/s
Kommentar:-
Source (alert[4]->info->description
as of this question were asked): https://opendata-download-warnings.smhi.se/api/version/2/alerts.json
I've tried with explode()
but after that, I am clueless of how I can remove
Var
and the others from the arrays.
array(5) {
[0]=>
string(4) "När"
[1]=>
string(45) "Sent lördag kväll och natt till söndag
Var"
[2]=>
string(34) "Främst norra Jämtland
Intensitet"
[3]=>
string(25) "Väst ca 21 m/s
Kommentar"
[4]=>
string(1) "-"
}
Here's how I want it to look like:
array(5) {
[0]=>
string(45) "Sent lördag kväll och natt till söndag"
[1]=>
string(34) "Främst norra Jämtland"
[2]=>
string(25) "Väst ca 21 m/s"
[3]=>
string(1) "-"
}
Here's how I tried so far:
$content = file_get_contents('https://opendata-download-warnings.smhi.se/api/version/2/alerts.json');
$content = json_decode($content);
foreach($content->alert AS $alert) {
if($alert->info->area->areaDesc == '013') {
$desc = explode(':', $alert->info->description);
$descc = explode("
", $desc); # Don't know how to explode by
since it returns an error; explode() expects parameter 2 to be string
echo '<pre>'; var_dump($desc); echo '</pre>';
}
}