Jump to content

help with implode


MDanz

Recommended Posts

when i echo count($words) it is 1.

 

but when i print_r($itemid)  it displays this.. 

Array ( [2] => 17 [3] => 15 [4] => 17 )

 

when i count($words) it should echo 3.

 

print_r($itemid);
$words = implode(" ", $itemid);

echo count($words);

Link to comment
Share on other sites

@OP

$words = implode(" ", $itemid);

echo count($itemid);

 

Would also work.

 

@Pikachu

For the purpose of this function, 'word' is defined as a locale dependent  string containing alphabetic characters, which also may contain, but not start  with "'" and "-" characters.

 

Array ( [2] => 17 [3] => 15 [4] => 17 )

Link to comment
Share on other sites

thanks for the help.

 

could i have help on this.

 

 

$oldarray = implode(" ", $itemid);

$newarray = explode(" ", $oldarray);

i have to do the above to reset the array index to start at zero.

 

how do i set a session array for $newarray? 

 

e.g. $newarray = 13 14 15

 

so i want the  session array to be

[0] =>13
[1] =>14
[2] =>15

 

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.