Created
June 12, 2012 21:31
-
-
Save ralphsaunders/2920260 to your computer and use it in GitHub Desktop.
PHP preg_grep() throws a notice when passed array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This is my array, let's call him larry | |
* | |
* array(1) { | |
* ["canvas-snake"]=> | |
* array(5) { | |
* ["name"]=> | |
* string(12) "canvas-snake" | |
* ["server_path"]=> | |
* string(48) "/Applications/MAMP/htdocs/pl/posted/canvas-snake" | |
* ["size"]=> | |
* int(374) | |
* ["date"]=> | |
* int(1339533162) | |
* ["relative_path"]=> | |
* string(9) "./posted/" | |
* } | |
* } | |
* | |
* | |
* A PHP Error was encountered | |
* | |
* Severity: Notice | |
* | |
* Message: Array to string conversion | |
* | |
* Filename: models/posts_model.php | |
* | |
* Line Number: 70 | |
*/ | |
/** | |
* pretty urls | |
*/ | |
$ugly_dirs = preg_grep( '/[A-Z]\S/', $larry ); | |
if( ! empty( $ugly_dirs ) ) | |
{ | |
/** | |
* Note: the code in here *does* run and does work, it's just preg_grep | |
* doesn't like larry... poor larry | |
*/ | |
foreach( $ugly_dirs as $dir ) | |
{ | |
rename( $root . $dir['name'], $root . $this->_format_url( $dir['name'] ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you ever figure out why this is happening? It sounds like a PHP bug.