[ create a new paste ] login | about

Link: http://codepad.org/SVk7FPx9    [ raw code | output | fork ]

PHP, pasted on Feb 21:
1
2
3
4
5
6
7
8
9
10
11
12
<?php

$string = 'Diabetes, Nutrition, Dietician';
$array = explode(',', $string);
$result = array();
foreach ($array as $part) {
    if (substr(strtolower(trim($part)),0,1) == 'd') {
        array_push($result, trim($part));
    }
}

var_dump($result);


Output:
1
2
3
4
5
6
array(2) {
  [0]=>
  string(8) "Diabetes"
  [1]=>
  string(9) "Dietician"
}


Create a new paste based on this one


Comments: