469,912 Members | 1,839 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,912 developers. It's quick & easy.

converting code using Java Vector to PHP

I've been given the task of converting some existing java code to PHP
so we can integrate it into our web based product.

The problem I'm facing is that the java code makes heavy use of Vector
objects to hold data. This in itself isn't a problem however the java
code makes heavy use of Vector.insertElementAt(). This method inserts
into the vector container at a desired location and shifts the indexes
of all the other items accordingly as necessary.

I don't see any way to really emulate this behavior in with PHP
arrays.

Any thoughts?

....
Krick
Jul 17 '05 #1
2 1983
On 29 Sep 2004 13:21:37 -0700, wk****@gmail.com (William Krick) wrote:
I've been given the task of converting some existing java code to PHP
so we can integrate it into our web based product.

The problem I'm facing is that the java code makes heavy use of Vector
objects to hold data. This in itself isn't a problem however the java
code makes heavy use of Vector.insertElementAt(). This method inserts
into the vector container at a desired location and shifts the indexes
of all the other items accordingly as necessary.

I don't see any way to really emulate this behavior in with PHP
arrays.

Any thoughts?


http://uk.php.net/manual/en/function.array-splice.php , see final example.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #2
William Krick <wk****@gmail.com> wrote:
I've been given the task of converting some existing java code to PHP
so we can integrate it into our web based product. The problem I'm facing is that the java code makes heavy use of Vector
objects to hold data. This in itself isn't a problem however the java
code makes heavy use of Vector.insertElementAt(). This method inserts
into the vector container at a desired location and shifts the indexes
of all the other items accordingly as necessary.


$input = array("red", "green", "blue", "yellow");
array_splice($input, 3, 0, "purple");
// $input is now array("red", "green",
// "blue", "purple", "yellow");

http://www.php.net/manual/en/function.array-splice.php

hope this helps

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Salil Das | It's ok to kiss a fool,
bugs@cc | It's ok to let a fool kiss you,
| but never ever let a kiss fool you.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by bdinmstig | last post: by
67 posts views Thread by Steven T. Hatton | last post: by
24 posts views Thread by cs_hart | last post: by
13 posts views Thread by ppateel | last post: by
3 posts views Thread by fakeprogress | last post: by
12 posts views Thread by steven acer | last post: by
1 post views Thread by java4life | last post: by
10 posts views Thread by Curious | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.