You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: php/lesson2/tutorial.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -113,15 +113,15 @@ Array
113
113
```
114
114
Err, wasn't expecting that? The PHP echo command has to convert values to strings to display them. Most of the time it knows what to do, but it doesn't like to second guess you so wants you to be more specific. So actually it's outputted the string `Array` and warned you with the `PHP Notice` line why it's not what you expected. We can use a `var_dump`, or a string function that can tell it how to format the array items. Here's an example:
115
115
```php
116
-
echo join(",", [4, 5, 6]);
116
+
echo implode(",", [4, 5, 6]);
117
117
```
118
118
This tells it to join each element in the array together with a comma, so the output becomes:
119
119
```
120
120
4, 5, 6
121
121
```
122
122
You don't have to have items of just one type in an array, you can mix them up. E.g:
0 commit comments