Giter Club home page Giter Club logo

30-seconds-of-php's Introduction

Logo

30 seconds of code

Short PHP code snippets for all your development needs

  • Visit our website to view our snippet collection.
  • Use the Search page to find snippets that suit your needs. You can search by name, tag, language or using a snippet's description. Just start typing a term and see what comes up.
  • Browse the PHP Snippet List to see all the snippets in this project or click individual tags at the top of the same page to narrow down your search to a specific tag.
  • Click on each snippet card to view the whole snippet, including code, explanation and examples.
  • You can use the button on the right side of a snippet card to copy the code to clipboard.
  • If you like the project, give it a star. It means a lot to the people maintaining it.

Want to contribute?

Credits & Sponsors

  • This repository is maintained by the 30-seconds organization on GitHub.
  • All snippets are licensed under the CC0-1.0 License, unless explicitly stated otherwise.
  • Logos, names and trademarks are not to be used without the explicit consent of the maintainers or owners of the 30 seconds GitHub organization.
  • Our website is powered by Netlify, Gatsby, Travis CI & GitHub.

30-seconds-of-php's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

30-seconds-of-php's Issues

Possible integration into 30-seconds organization

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:

  • Main person(s) responsible for the repository after the transfer (i.e. team leaders, up to 3 people).
  • Any other people who should be part of the organization as members of the PHP team.

If you have any questions and/or concerns, please feel free to ask me about them.

[NOTICE/DISCUSSION] Migration to new infrastructure

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:

  • Update logo to match the style of the other repositories (@Chalarangelo)
  • Update snippets to the new format and match quality standards (open)
  • Remove leftover scripts, code, systems etc [1] (@fejes713)
  • Copy systems, scripts, tools from 30-seconds/30-seconds-starter and configure accordingly (@fejes713)
  • Update static parts, guidelines, issue/PR templates (@fejes713)
  • Add Google Analytics, DNS records for php.30secondsofcode.org (@Chalarangelo)
  • Rename to 30-seconds-of-php (all existing links are handled automagically by GitHub to point to the new name) (@Chalarangelo)
  • Set up Travis CI and Netlify (@Chalarangelo)

Notes

  • [1]: If you want, you can keep parts of the existing infrastructure (e.g. a testing system or something similar), as long as you maintain them and keep them up to date and provide us with guidelines and/or help during the migration process on how to integrate them to the new template.

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.

Missing unit test work after changing code snippet building process

Description

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 :).

Not 100% safe average example

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 >

Is function decapitalize correct ?

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));
}

Trying to understand "useless" code

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?

Starts With and strpos?

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!

finstLast example is lacking

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?

Readme.md typo

Accordly with Contribution Guide, i point out some typo on README.md.

  • Function minN, in the example maxN is called.
  • Function decapitalize, in the description i think you mean "string" instead of "sring".
  • Function groupBy, in the example a semicolon is missing.

GC

variadicFunction

https://github.com/appzcoder/30-seconds-of-php-code#variadicfunction

I do not really understand this example, for many reasons :

  • variadic functions are functions that takes any number of parameters and then aggregates them into one array with the syntax ...$operands, but here you're just passing an array
  • for the demonstration, you're mimicking the array_sum function

So, 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

Update Note message in README

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?

pull vs without

I don't get what is the difference between pull() and without().

isContains pointless

Another pointless snippet; isContains.

It's wrapping a super basic function and offers nothing new.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.