By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,441 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,441 IT Pros & Developers. It's quick & easy.

converting code using Java Vector to PHP

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.