0

hi guys,

this is danny and i need a little help frm u guys

i have a piece of code which i need to explode

EXP=482900\_1SKILL=4294967295;4294967295;4294967295\_1PK=0\_1RTM=0\_1SINFO=655391\_1WEAR=17408;2145;4294967295;19666;3105;4294967295;19656;4129;4294967295;19661;5153;4294967295;19676;6177;4294967295;19671;7201;4294967295\_1INVEN=\_1

explode("\_1",$charstring);  explode("SKILL=",$temp[0]);

i just want to edit 4294967295;4294967295;4294967295 after skill can u guys pls guide me how do i implode after editing i am losing everything while imploding wat should i do ..

is there any other function other than this !!
its very urgent !! Thanx in advance for ur help

3
Contributors
6
Replies
7
Views
8 Years
Discussion Span
Last Post by daneuchar
0

sry for just writting a small part of the code heres the full code !!

<?php
//initializing string
$sqlstring="select m_body from charac0 where c_id = '$char'";
$rsstring=odbc_exec($con,$sqlstring);
$charstring = odbc_result($rsstring,'m_body');
//echo "$charstring <br>";

//explode the string
$temp = explode("\_1",$charstring);

//initialize variable for the string
$EXP = explode("=",$temp[0]);
$SKILL = explode("=",$temp[1]);
$PK = explode("=",$temp[2]);
$RTM = explode("=",$temp[3]);
$SINFO = explode("=",$temp[4]);
$WEAR = explode("=",$temp[5]);
$INVEN = explode("=",$temp[6]);
?>

after the above code i am using this in another php i am lossing all except 1st 2 string 

	//change the skill database
		$SKILL[1] = "4294967295;4294967295;4294967295";

$newString = $temp[0]."\_1".$SKILL[0]."=".$SKILL[1]."\_1".$temp[2]."\_1".$temp[3]."\_1".$temp[4]."\_1".$temp[5]."\_1".$temp[6]."\_1";
0

You can do:

$array = array_filter( explode( '\_1',$charstring ) );
$data = array();
foreach( $array as $part ) {
  list( $key,$val ) = explode( '=',$part );
  $data[$key] = $val;
}
//edit skill here using
$data['SKILL'] = 'something.....';
$array = array();
foreach( $data as $key => $val ) {
  $array[] = "{$key}={$val}";
}
$charstring = implode( '\_1',$array );

Might be overkill but makes it so it will work even if the layout of the string changes.

0

YEA that was nice doc but wat about other elements of the exploded body ...!! i just need to change wat ever is after skill = till \_1

pls guide me sorry for being such a noob new to php and i am developing a mmorpg but finding hard with this php thing :(

0

thanx a lot doc!! i am working on imploding not getting it rite so will let u knw ..!! as i complete it..! thanx a billion for this help !!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.