note 109307 added to function.array-slice
| From: | dayanneramosweb at gmail dot com | Date: | Wed, 04 Jul 2012 18:51:35 +0000 |
| Subject: | note 109307 added to function.array-slice | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-189031@lists.php.net to get a copy of this message | ||
function array_push_in_position($arrayAInserir,$indiceInserir,$insercao){
$parte1 = array_slice($arrayAInserir,0,$indiceInserir);
$parte2 = array_slice($arrayAInserir,$indiceInserir);
array_push($parte1,$insercao);
return array_merge($parte1,$parte2);
}
//ex: quero inserir a palavra house, apos apos a melon.
$words = array('banana','melon','car');
$words = array_push_in_position($words ,2,'house');
/* result:
array(4) {
[0]=>
string(6) "banana"
[1]=>
string(5) "melon"
[2]=>
string(5) "house"
[3]=>
string(3) "car"
}
*/
----
Server IP: 69.147.83.197
Probable Submitter: 189.26.212.244
----
Manual Page -- http://www.php.net/manual/en/function.array-slice.php
Edit -- https://master.php.net/note/edit/109307
Del: integrated -- https://master.php.net/note/delete/109307/integrated
Del: useless -- https://master.php.net/note/delete/109307/useless
Del: bad code -- https://master.php.net/note/delete/109307/bad+code
Del: spam -- https://master.php.net/note/delete/109307/spam
Del: non-english -- https://master.php.net/note/delete/109307/non-english
Del: in docs -- https://master.php.net/note/delete/109307/in+docs
Del: other reasons-- https://master.php.net/note/delete/109307
Reject -- https://master.php.net/note/reject/109307
Search -- https://master.php.net/manage/user-notes.php