Kod
Dec 2 13:24:40 zzz sshd[7317]: Failed password for bin from xx.xx.xx.xx port 39817 ssh2
a do niego taki wzór Kod
/^([a-zA-Z]{3})( {1,2})([0-9]{1,2}) ([0-9]{2}):([0-9]{2}):([0-9]{2}) (.*?) (.*?): (.*?)$/
Preg_match zwraca Kod
array(10) {
[0]=>
string(95) "Dec 2 13:24:40 zzz sshd[7317]: Failed password for bin from xx.xx.xx.xx port 39817 ssh2"
[1]=>
string(3) "Dec"
[2]=>
string(2) " "
[3]=>
string(1) "2"
[4]=>
string(2) "13"
[5]=>
string(2) "24"
[6]=>
string(2) "40"
[7]=>
string(3) "zzz"
[8]=>
string(10) "sshd[7317]"
[9]=>
string(56) "Failed password for bin from xx.xx.xx.xx port 39817 ssh2"
}
a chciałbym aby zwrócił tylko i wyłącznie ostatni element tablicy. Wiem, że mogę to zrobić po prostu w kodzie np. [0]=>
string(95) "Dec 2 13:24:40 zzz sshd[7317]: Failed password for bin from xx.xx.xx.xx port 39817 ssh2"
[1]=>
string(3) "Dec"
[2]=>
string(2) " "
[3]=>
string(1) "2"
[4]=>
string(2) "13"
[5]=>
string(2) "24"
[6]=>
string(2) "40"
[7]=>
string(3) "zzz"
[8]=>
string(10) "sshd[7317]"
[9]=>
string(56) "Failed password for bin from xx.xx.xx.xx port 39817 ssh2"
}
ale mi chodzi o to aby we wzorze wyrażenia ograniczyć elementy, które maja być zwracane. Ewentualnie może zwracać tablicę z ustalonymi kluczami tak, żeby np zamiast klucza 9 była treść. Czy jest to możliwe?
$arr[9]