Jump to content

split function no longer used?


EchoFool

Recommended Posts

I just seen here:

 

http://php.net/manual/en/function.split.php

 

This comment;

This function has been DEPRECATED as of PHP 5.3.0 and REMOVED as of PHP 6.0.0. Relying on this feature is highly discouraged.

 

 

I was about to use this to separate two arrays which are joined in a input "name" like this :

<input type="input" name ="RecordID[<?php echo $row['RecordID'];?>],Value[]" value"">

 

I was going to use split on the "," value so i had both values in an array to process but now it says not to use the function - so what should i do to get the values out ?

Link to comment
https://forums.phpfreaks.com/topic/183669-split-function-no-longer-used/
Share on other sites

Okay - final question - if I'm passing an array in my input box, and i have this instead:

 

<input type="input" name ="Value[]" value"">

 

But i need it to pass an array where it has the value="" that the user inputted + a record id to with it.. how can that be done in the value box without record ID being displayed?

 

So its like

[key] : "RecordID" "Input Value"

Example:

 

[0] = "1"  "25"

 

Record id is a $RecordID from the while loop i should add.

assuming the recordID is unique, explicitly name the Value[] array element with it, like name="Value[$recordID]"

 

then when user posts it, the array keys are your record IDs and the values are the values the user submitted, associated with it. 

Yeh i tried that but then i had one issue again.

 

Cos i tried this;

 

<?php
$Var = $_POST['Value'];
foreach($Var As $Values){
Echo $Values[0] // recordID
Echo $Values[1] // input value
]
?>

 

Which didn't work i can get input value but i cannot grab record id from the array ?

no that's not quite right.  Say you have this:

 

//pseudocode
while (...) {
   <input type = 'text' name='Value[$recordID]' />
}

 

Then your code would look more like this (for example):

 

<?php
$values = $_POST['Value'];
foreach($values As $key => $val){
echo $key; // recordID
echo $val; // input value
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.