0

I need to use php and extract the items from the string and assign them to variables.

$string = "76305203 ;124400884 ;109263187 ;current ;18.44";

How can I get:

$var1 = 76305203
$var2 = 124400884
0

1 Answer 1

3

To create variables use list()

<?php

$string = "76305203 ;124400884 ;109263187 ;current ;18.44";

list($var1,$var2) = explode(';', $string);

echo $var1;

echo PHP_EOL;

echo $var2;

Output:- https://eval.in/928536

Or use explode() to get array and use that array

<?php

$string = "76305203 ;124400884 ;109263187 ;current ;18.44";

$array = explode(';', $string);

echo $array[0];

echo PHP_EOL;

echo $array[1];

Output:-https://eval.in/928537

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.