homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

php problem
shifting a array

 2:32 am on Nov 12, 2002 (gmt 0)

say i have a array:


And i need to insert 3 (*) empty arrays on location $lines[1] (**) and everything under $lines[1] (**) it must also shift 3 (*) arrays down.

So the result would be:


Is there a PHP command for this?

i couldn't find one that does exactly this. And i got a really weird error message with all weird characters, when i tried to make my own code to do this, and run it on the server.

The code i come up with was:(please don't laugh, i'm new to php, so my code is probably bad)

$filename = 'bestand.txt';
$lines = file($filename);

while ($teller!=$startnummer)

But i got this really weird message.

Can anybody help me out?

(*) i need 3 lines and sometimes just 1 line.
(**) $lines[1] is just an example, it could also be $lines[100] where the 'blank' arrays need to be inserted.



 5:37 am on Nov 12, 2002 (gmt 0)

You can achieve this using array_slice() [php.net] to split the original array in two, and array_merge() [php.net] to insert a third array containing the blank elements.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved