Jump to content

Help with string stuff


rondog

Recommended Posts

I have a string:

"system_controllers_qty"

 

and i need it to be:

"system_controllers.system_controllers_qty"

 

I can use substr because the It wont always be 'system_controllers', it can be 'system_cpus' for example so I need to somehow break and the second underscore if possible. Any ideas?

Link to comment
Share on other sites

This works, but if you guys have a cleaner solution leme know, thanks!

<?php
$str = "system_controllers_qty";
$formatted = explode("_",$str);
$formatted = $formatted[0] . "_" . $formatted[1] . "." . $str;
echo $formatted; //system_controllers.system_controllers_qty
?>

Link to comment
Share on other sites

Let me get this straight, are you wanting to break the string

  'system_controllers.system_controllers_qty'

so it looks like

  'system_controllers.system'

 

If this is the case, then let me know, if not, explain a little more bud.

 

Regards, Paul.

 

Looks like we posted at the same time. Refer to my post

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.