Rana Pratap
Rana Pratap

Reputation: 55

convert a php string to php array based on a character

This is my php string --

Advertiser ID\tCompany\tManager\tContact Person\tIM_Skype

Now need to convert it to array based on "\t".

how to achieve this?

Upvotes: 0

Views: 52

Answers (1)

Death-is-the-real-truth
Death-is-the-real-truth

Reputation: 72299

1. In case of string have single-quote then using explode()

<?php

    $string = 'Advertiser ID\tCompany\tManager\tContact Person\tIM_Skype';
    $array = explode('\t',$string);
    print_r($array);

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

2. In case of string have double-quote then

<?php

    $string = "Advertiser ID\tCompany\tManager\tContact Person\tIM_Skype";
    $array = explode("\t",$string);
    print_r($array);

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

Upvotes: 5

Related Questions