Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated php.php line 20 str_replace to ver PHP 8.0 #300

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion languages/php.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$string = 'Awesome cheatsheets';

str_contains($string, 'cheat'); // Find if the string contains the specified string (PHP >= 8.0)
str_replace('Awesome', 'Bonjour', $string); // Replace all occurence
str_replace('Awesome', 'Bonjour', $string, $count); // Replace all occurence

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both forms are valid, but we should leave the two lines and say that the $count variable is used to contain the number of replacements made.

strcmp($string, 'Awesome cheatsheets'); // Compare two strings
strpos($string, 'a', 0); // Get position in the string
str_split($string, 2); // Split the string
Expand Down