chalarangelo / 30-seconds-of-php Goto Github PK
View Code? Open in Web Editor NEWShort PHP code snippets for all your development needs
Home Page: https://www.30secondsofcode.org/php/p/1
License: Creative Commons Zero v1.0 Universal
Short PHP code snippets for all your development needs
Home Page: https://www.30secondsofcode.org/php/p/1
License: Creative Commons Zero v1.0 Universal
Hi there!
Curious about the example for startsWith
. Is there a reason 0 === strpos( $haystack, $needle )
wasn't used? If not, happy to open a PR- from my understanding, strpos
is much faster.
Thanks!
For example http://python.kriadmin.me/
Is needed this?
For example https://github.com/30-seconds/30-seconds-of-php/blob/master/snippets/findLast.md
Why does this snippet exist? What is the knowledge here?
As title, I think we can consider adding the Date
section to learn about simple date manipulation in 30-seconds
with PHP.
@sohelamin, what do you think about this?
As title, since we've changed the code snippets building process, some works are missed during Travis CI build.
As we look at the .travis.yml, it only has the code snippets building and it doesn't have any unit test works to validate these code snippet behaviors reliable and expected.
And it also misses the section of how-to test cases writing
on CONTRIBUTING.md
IMHO, we should add this back and add contributing tips about unit test writing.
@sohelamin, and @Chalarangelo, please concern this at your available time.
And recommend current solution to accomplish this issue.
Thanks :).
The problem is with a find or find last you need an example that demonstrates what happens if there are two or more elements that satisfy the condition:
findLast([1,2,3,4,5]); // 5 || 3?
Despite "realiness" of following example I think it'd be good if it would be mistake proof, especially when it's something for others to learn from.
php > echo average(1,3,4,5);
3.25
php > echo average();
Warning: Division by zero in php shell code on line 3
NAN
php >
I don't get what is the difference between pull() and without().
I've made a simple function that shortens a string to a given length and appends an optional string to show it's been shortened.
I've got the code snippet in a .md
file but don't know how to test the build process.
https://github.com/StyxOfDynamite/30-seconds-of-php-code/blob/master/snippets/shorten.md
Another pointless snippet; isContains.
It's wrapping a super basic function and offers nothing new.
https://github.com/appzcoder/30-seconds-of-php-code#variadicfunction
I do not really understand this example, for many reasons :
...$operands
, but here you're just passing an arrayarray_sum
functionSo, correct me if I'm wrong, but your example of a variadic function should be :
function variadicFunction(int ...$operands) : int
{
return array_sum($operands);
}
variadicFunction(1, 2); // 3
variadicFunction(1, 2, 3, 4); // 10
Hey there, @30-seconds/php team! How's it going?
As you might have noticed, we are migrating repositories toa new, unified structure and template to make it easier for the core teams to maintain them. I will outline below the list of changes we are thinking of making and you can pitch in and help us (me and @fejes713) figure out the best fit and timeline for this all:
Nothing is set in stone yet, but we are trying to get all repositories set up with the new template (check the 30-seconds-of-code and 30-seconds-of-python repositories to see what this looks like) and build it all up as soon as possible. However, we are asking each team to make sure there are as few issues with this as possible, so I'd love to get some feedback from you, guys. If you don't have time to participate in this procedure (which is absolutely fine), I and @fejes713 will take care of pretty much everything, so no worries, just respond below so that we know.
Hello, everyone! Our GitHub organization would love to have you as part of the team. You will, of course, retain all rights to your code and repository, write access and all the good stuff. The only thing that changes is that the 30-seconds team will be able to help more often with your project's needs and you will get to have access to all our communication channels.
If you are interested, please reply with the following:
PHP
team.If you have any questions and/or concerns, please feel free to ask me about them.
As title, some messages I think we need to be changed since this repository is the part of 30-seconds
organization.
The messages are as follows:
Note: This project is inspired by 30 Seconds of Code, but there is no affiliation with that project.
This message I think should be removed/changed.
@sohelamin, what do you think about changing this description?
function decapitalize($string, $upperRest = false)
{
return strtolower(substr($string, 0, 1)) . ($upperRest ? strtoupper(substr($string, 1) : substr($string, 1));
}
function decapitalize($string, $upperRest = false)
{
return strtolower(substr($string, 0, 1)) . ($upperRest ? strtoupper(substr($string, 1)) : substr($string, 1));
}
I am trying to understand the sense (strategy? meaning?) behind a function like the following:
function chunk($items, $size)
{
return array_chunk($items, $size);
}
There is nothing to it, and only the array part of the function name is dropped. Is this something where all "30 seconds of ***" must have a chunk
function or is it one of these "organically grown" functions that were not available in PHP before version X?
Accordly with Contribution Guide, i point out some typo on README.md.
GC
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.