|
-
Sep 27th, 2007, 05:00 PM
#1
[RESOLVED] Insert Into Array
I need to insert a couple of new items into an existing populated array but I want to insert them in a particular position that may not always be the same.
I started out using array_push but that just appends the array. I figure some kind of function that will iterate through the array looking for a match and then do the insert.
Thanks
PHP Code:
array_push($myitems, 'item6', 'item7', 'item8');
Edit: 44,444 posts lol
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 28th, 2007, 12:05 PM
#2
-
Sep 28th, 2007, 12:59 PM
#3
Re: Insert Into Array
Nope, didnt have but I looked through the entire list and nothing pre-existing for this.
So if this was vb I would iterate through the array until I found the position where I wanted my new items inserted. Then take that first part of the array and insert it into a temp array. Take the second half and place that into another temp array. Then merge the three arrays with my insertion array as the second array to merge. Final output would go back into the original array.
Ok ho do in php
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 28th, 2007, 07:34 PM
#4
Re: Insert Into Array
why does it need to be in a special order? here is what array_push does
your array - "item1", "item2", "item3"
add - "item8", "item9"
new array - "item1", "item2", "item3", "item8", "item9"
My usual boring signature: Something
-
Sep 29th, 2007, 12:51 AM
#5
Re: Insert Into Array
Yes, I know what array_push does as I mentioned it appends to the end of an array. Well I got help already on this and am returning to resolve 
Im using array_slice, array_search, and array_merge to do the task laidout in post #3.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|