How would I split this string:
So it comes out like this:
$type = 'item';
$id = '35';
I know there are a lot of string fucntions but I have no idea what would be easiest.
Maybe implode(), an array would be fine
or one of the other string functions.
Implode does the opposite
Okay cool, thanks.
I was looking up strsplit() and forgot implode/explode, yeah its explode lol.
I did this:
$a = explode('.', $id);
That will work!
There are a multitude of different ways to achieve such a simple task. Here's a few (you already know about the first one):
// 1. EXPLODE! *pop*
list($type, $id) = explode('.', 'item.35', 2);
// 2. Scan a formatted string
list($type, $id) = sscanf('item.35', '%[a-z].%d');
This topic is now closed. New replies are no longer allowed.