| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function uniqueMultiDim($key) |
||
| 16 | { |
||
| 17 | $tempArray = array(); |
||
| 18 | $i = 0; |
||
| 19 | $keyArray = array(); |
||
| 20 | |||
| 21 | foreach($this->array as $val) { |
||
|
|
|||
| 22 | if (!in_array($val[$key], $keyArray)) { |
||
| 23 | $keyArray[$i] = $val[$key]; |
||
| 24 | $tempArray[$i] = $val; |
||
| 25 | } |
||
| 26 | $i++; |
||
| 27 | } |
||
| 28 | |||
| 29 | $this->array = $tempArray; |
||
| 30 | return $this; |
||
| 31 | } |
||
| 32 | } |
||
| 33 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: