· 9 years ago · Feb 19, 2017, 10:46 AM
1<?php
2
3$string = 'To jest ciekawy napis';
4function test($string)
5{
6 $array = explode(' ', strtolower($string));
7 for ($i = 1; $i < count($array); $i += 2) {
8
9 $array[$i] = strtoupper($array[$i]);
10
11 }
12 return implode('_', $array);
13}
14
15//echo test($string);
16
17
18/////
19function foundAndReplace($array)
20{
21 $res = [];
22 for ($i = 0; $i < count($array); $i++) {
23 $res[] = strpos($array[$i], '@');
24 $array[$i] = strstr($array[$i], '@', true) . '@gmail.com';
25
26 echo $array[$i] . '<br>';
27 }
28
29 return $res;
30}
31
32$mailList = ['john.doe@interia.pl', 'mark.willow@wp.pl'];
33echo '<pre>';
34print_r(
35 foundAndReplace($mailList)
36);
37echo '</pre>';