Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7577503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:12:06+00:00 2026-05-30T17:12:06+00:00

I wants to divide the string in table and my need is output: //

  • 0

I wants to divide the string in table and my need is

output:

// First Output
$name ='aaaa';
$first='DUT.A1';
$second='E3.3 H2.3 Y3.333 h88.h fdfd.87';
$third ='J66.H3';

// SecondOutput
$name ='bbbb';
$first='DUT.A2';
$second='F2.2 F3.1 Y1.1';
$third ='J30.A1';

Input:

$a  = "aaaa ; DUT.A1 E3.3 H2.3 Y3.333 h88.h fdfd.87 J66.H3";
$b  = "bbbb ; DUT.A2 F2.2 F3.1 Y1.1 J30.A1";
$c  = "cccc ; DUT.A3 H2.3 Y3.333 h88.h Y1.1 J45.G2";

A use explode function to divide the variable like

$exp = explode(";",$a);
$name = $exp[0];
$x = $exp[1];
$x1 = explode(" ",$x);
$total = count($x1);
$first = $x1[1];
$loop_end = $total-2;

for($i=2;$i<=$loop_end;$i++) {
    $second .= $x1[$i]."";
}
$third = $x1[$total-1]

;

Using to display Above output.

if i give,

$var  = "haha ; J1.A1 DUT.A1  DUT.A2 C1.1 C2.1 ,
              F2.1 F4.1 K1.1 ,
              F2.1 F4.1 K1.1 ,
              F2.1 F4.1 K1.1 "; 

I wants Before Semicolon as name, String like DUT.xx as first(no spaces included ex.DUT.A1 DUT.A2)
The Character starts with J and After Numeric value it stored in third(ex.J1.A1 as third
not J after Character). Balance Characters stored in variable Second, like (ex.

$second =  'C1.1 C2.1,F2.1 F4.1 K1.1,F2.1 F4.1 K1.1,F2.1 F4.1 K1.1';

)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T17:12:08+00:00Added an answer on May 30, 2026 at 5:12 pm

    Is this the desired output?

    $arr = array(
        "aaaa ; DUT.A1 E3.3 H2.3 Y3.333 h88.h fdfd.87 J66.H3",
        "bbbb ; DUT.A2 F2.2 F3.1 Y1.1 J30.A1",
        "cccc ; DUT.A3 H2.3 Y3.333 h88.h Y1.1 J45.G2",
        "haha ; J1.A1 J1.A2 DUT.A1  DUT.A2 C1.1 C2.1 ,F2.1 F4.1 K1.1 ,F2.1 F4.1 K1.1 ,F2.1 F4.1 K1.1 ");
    
    
    foreach ($arr as $item) {
        echo "<b>item</b> = $item<hr/>";
        $parts = preg_split('/\s*;\s*/',$item);
    
        $name = $parts[0];
        $first = array();
        $second = array();
        $third = array();
    
        $split = preg_split('/\s*,\s*/',$parts[1]);
    
        foreach ($split as $values) {
            preg_match_all('/\b[\w\d]+\.[\d\w]+\b/',$values,$value);
            $sec = array();
            foreach ($value[0] as $item) {
                preg_match('/^DUT\./',$item,$match);
                if (!empty($match[0])) {
                    $first[] = $item; continue;
                }
                preg_match('/^J\d+\./',$item,$match);
                if (!empty($match[0])) {
                    $third[] = $item; continue;
                }
                $sec[] = $item;
            }
            $second[] = implode(' ', $sec);
        }
    
        $first = implode(' ', $first);
        $second = implode(',', $second);
        $third = implode(' ', $third);
    
        echo 'name = ' . $name . "\n";
        echo 'first = ' . $first . "\n";
        echo 'second = ' . $second . "\n";
        echo 'third = ' . $third . "\n\n";
    
    }
    

    item = aaaa ; DUT.A1 E3.3 H2.3 Y3.333 h88.h fdfd.87 J66.H3


    name = aaaa
    first = DUT.A1
    second = E3.3 H2.3 Y3.333 h88.h
    fdfd.87
    third = J66.H3

    item = bbbb ; DUT.A2 F2.2 F3.1 Y1.1 J30.A1


    name =
    bbbb
    first = DUT.A2
    second = F2.2 F3.1 Y1.1
    third =
    J30.A1

    item = cccc ; DUT.A3 H2.3 Y3.333 h88.h Y1.1 J45.G2


    name =
    cccc
    first = DUT.A3
    second = H2.3 Y3.333 h88.h Y1.1
    third = J45.G2

    item = haha ; J1.A1 J1.A2 DUT.A1 DUT.A2 C1.1 C2.1 ,F2.1 F4.1
    K1.1 ,F2.1 F4.1 K1.1 ,F2.1 F4.1 K1.1


    name = haha
    first =
    DUT.A1 DUT.A2
    second = C1.1 C2.1,F2.1 F4.1 K1.1,F2.1 F4.1
    K1.1,F2.1 F4.1 K1.1
    third = J1.A1 J1.A2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display the first and last characters of any given string entered
I need to sum 2 decimal values together, then divide by 2 and convert
I'm trying to divide a string into parts for reading Roman numerals. For example
I have the string 001-1776591-7 , and I want to divide it into 3
I have a customer table, which has a field categories. It's a string holding
I'm working with a multi line text block where I need to divide everything
i am using my_colors.split( ) method, but i want to split or divide string
Given class public class SomeType { public string Name; public string Field2; public DateTime
I want to divide the window into 2 parts. Each part I can draw
i m the beginner in iphone. I want the divide the circle in equal

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.