Code Monkey home page Code Monkey logo

Comments (6)

cmrcx avatar cmrcx commented on July 26, 2024 1

I started writing a replacement for array_splice():

/**
 * replacement for broken array_splice() in PHP 7
 * https://bugs.php.net/bug.php?id=70471
 *
 * @param array   $input (reference)
 * @param integer $offset
 * @param integer $length
 * @param array   $replacement ()
 */
function array_splice_fixed(array &$input, $offset, $length=null, array $replacement=array()) {
	if ($offset < 0) {
		$left = array_slice($input, $offset);
	} else {
		$left = array_slice($input, 0, $offset);
	}
	if (is_null($length)) {
		$input = array_merge($left,	$replacement);
	} elseif ($length < 0) {
		$input = array_merge($left,	$replacement, array_slice($input, $length));
	} else {
		$input = array_merge($left, $replacement, array_slice($input, $offset + $length));
	}
	for ( $i = 0; $i <= count($replacement); $i++ ) {
		next($input);
	}
}

It works in my test script, but not in phptidy so far.

from phptidy.

schmunk42 avatar schmunk42 commented on July 26, 2024

Any chance to simulate the PHP 5 behavior with a custom function?
I really miss this on PHP 7 :(

from phptidy.

cmrcx avatar cmrcx commented on July 26, 2024

Can you please test a little bit, before I make the release?

from phptidy.

schmunk42 avatar schmunk42 commented on July 26, 2024

No problems so far, I tried it in several different projects.

You may also create a 2.18-beta1 or 2.18-rc1 tag first, this would make it much easier to test the newer version (instead of dev-master)

from phptidy.

cmrcx avatar cmrcx commented on July 26, 2024

Thank you very much for testing!

And yes, next time when I ask for testing, I'll make a tag for it. Thanks for the suggestion.

from phptidy.

schmunk42 avatar schmunk42 commented on July 26, 2024

Good decision to make a 3.0!

from phptidy.

Related Issues (17)

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.